5

I'm using pdflatex to create PDF versions of LaTeX equations. My requirement is simply that an equation appear with a bit of whitespace around it, not on a "page".

Some example code

\documentclass{minimal}
\usepackage{amsmath}
\usepackage[paperwidth=\maxdimen,paperheight=\maxdimen]{geometry}
\usepackage[active,tightpage]{preview}
\usepackage{amssymb}
\usepackage{bbm}
\setlength\PreviewBorder{5pt}

\begin{document}
\begin{preview}
$\displaystyle \left[\begin{array}{c|cc}
a & b & c \\ \hline
d & e & f \\
g & h & i
\end{array} \right]$
\end{preview}
\end{document}

I've had no issues save for the fact that the lines specified by the "|" and "\hline" don't appear. I assume this has something to do with the document class or environments I'm using since the lines appear properly in typical document classes such as "article".

The spacing between matrix elements also differs from the typical case, although this I can deal with.

Ideally I'd like the equation to appear just as it would as a display style equation in a typical document, but I'll settle for the lines showing up.

Any ideas on changes I can make to the code to remedy this issue?

I'd appreciate any assistance.

  • Why are you using the minimal document class? It should never be used for real production work. Please note that the often-repeated request for Minimum Working Examples does not entail using theminimal document class... – Mico Mar 15 '17 at 18:29
5

Changing to article document class works, as hoped. Perhaps minimal is too minimal. I have heard it advocated not to use the minimal document class, in general.

Also, the geometry package call appears to be superfluous, in the presence of the preview package, so I comment it out in my answer.

\documentclass{article}
\usepackage{amsmath}
%\usepackage[paperwidth=\maxdimen,paperheight=\maxdimen]{geometry}
\usepackage[active,tightpage]{preview}
\usepackage{amssymb}
\usepackage{bbm}
\setlength\PreviewBorder{5pt}

\begin{document}
\begin{preview}
$\displaystyle \left[\begin{array}{c|cc}
a & b & c \\ \hline
d & e & f \\
g & h & i
\end{array} \right]$
\end{preview}
\end{document}

enter image description here

  • Ah. Thank you. I originally got the code off this site and assumed the "minimal" class was needed to make it work. – COTO Mar 15 '17 at 18:20
  • @COTO Apparently, the preview package makes it possible. It would also appear the geometry package call is superfluous, so I will remove it from my answer. – Steven B. Segletes Mar 15 '17 at 18:22
7

The minimal class only defines the normal font. Several parameters are only initialized in the format and it's the duty of the class to set them.

In particular, minimal doesn't set \arrayrulewidth. Here's an excerpt from article.cls (line numbers are for reference)

442 \setlength\arraycolsep{5\p@}
443 \setlength\tabcolsep{6\p@}
444 \setlength\arrayrulewidth{.4\p@}
445 \setlength\doublerulesep{2\p@}
446 \setlength\tabbingsep{\labelsep}
447 \skip\@mpfootins = \skip\footins
448 \setlength\fboxsep{3\p@}
449 \setlength\fboxrule{.4\p@}

The standard reference for this is Why should the minimal class be avoided?

You could use the minimal class, just add

\setlength{\arrayrulewidth}{0.4pt}

to the preamble. But it's easier using article and doing \pagestyle{empty}. Even better

\documentclass[border=5pt]{standalone}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{bbm}

\begin{document}

$\displaystyle \left[\begin{array}{c|cc}
a & b & c \\ \hline
d & e & f \\
g & h & i
\end{array} \right]$

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.