# Is there an option to trim the remaining whitespace to the right?

\documentclass{article}
\usepackage[active,tightpage]{preview}
\PreviewBorder=12pt
\begin{document}
\begin{preview}
$\frac{1}{3}=0.333\ldots \Rightarrow 1=3\times\frac{1}{3}=3\times 0.333\ldots=0.999\ldots$\\
Thus $1=0.999\ldots$.
\end{preview}
\end{document}


Is there an option to trim the remaining whitespace to the right?

-

The extra whitespace you see is because a paragraph with the width \linewidth is created here. You can use the {varwidth}{<max width>} environment from the varwidth package to reduce the paragraph width to its minimum. This uses a minipage environment internally.

\documentclass{article}
\usepackage{varwidth}
\usepackage[active,tightpage]{preview}
\PreviewBorder=12pt
\begin{document}
\begin{preview}
\begin{varwidth}{\linewidth}
$\frac{1}{3}=0.333\ldots \Rightarrow 1=3\times\frac{1}{3}=3\times 0.333\ldots=0.999\ldots$\\
Thus $1=0.999\ldots$.
\end{varwidth}
\end{preview}
\end{document}


You can also use the standalone class with the preview and varwidth=<max width|default: \linewidth> options which will use more or less the exact same code internally:

\documentclass[varwidth,preview,border=12pt]{standalone}
\begin{document}
$\frac{1}{3}=0.333\ldots \Rightarrow 1=3\times\frac{1}{3}=3\times 0.333\ldots=0.9 99\ldots$\\
Thus $1=0.999\ldots$.
\end{document}


Also the default option crop works here instead of preview but does not use the preview package internally.

-
Why do you provide preview option if crop works? In other words, is there a case in which you need to load preview package in standalone.cls implementation? – kiss my armpit Jan 26 '13 at 15:02
@GarbageCollector: In the first version of standalone (v0.x) I used the preview package to crop the content. However, this showed some issues (e.g. with XeLaTeX and PDF patterns) and limitations, so I started to write my own cropping code which I called crop. I made it the default with v1.x, but I still provide the original preview option which used to be the default. If used it loads the preview package. – Martin Scharrer Jan 26 '13 at 15:05
Without considering the issues you mentioned above, is crop better than preview? For example, is crop more accurate than preview, etc, etc? – kiss my armpit Jan 26 '13 at 15:10
@GarbageCollector: No, its not more accurate. Both simply use the official dimensions of the content. However, crop does use restricted horizontal mode (like in \mbox) to store the content, which avoids the issue of getting a paragraph when having a trailing empty line after a small picture environment, but doesn't work with content which depends on vertical mode, like display-math. For this you need to use varwidth around the content first. AFAIK preview works using the output routine, which might clash with other code which modifies this. crop simply resizes the page. – Martin Scharrer Jan 26 '13 at 15:15