# What document class should I use for a variable size image generator

Currently, whenever I want to make a math image, I head over to my Wikipedia Sandbox and use the WP math tag(which uses TeX). I then copy the image from the preview.

I have TeXmaker (from USBTeX), and I'd like to use it more often. The issue is, I can't find a way to create a page that is cropped to the size of the content. So The most I can do is use \documentclass[]{slides} and crop it with Paint--clearly inefficient.

What would be nice would be something which autosizes each page based on its contents. Does something like this exist??

-
– Martin Scharrer Apr 12 '12 at 8:27

The standalone document class does this out-of-the-box, creating a cropped version of the document content. Here's a small example:

\documentclass{standalone}% http://ctan.org/pkg/standalone
\begin{document}
$E=mc^2$
\end{document}


Setting a border (of whitespace) around the cropped output is as simple as supplying the option [border=<len>] to the document class (where <len> is any known TeX dimension). See the standalone documentation for more options.

If you enjoy pagination and would like to create "a bunch at a time", you could use the multi option/key-value from standalone (example below from Martin Scharrer) or the preview package and wrap each "page" inside a preview environment:

\documentclass[multi=math,border=1]{standalone}
\usepackage{amsmath}% always a good idea when using math
\begin{document}
\begin{math}
E=mc^2
\end{math}

\begin{math}
\sin^2x+\cos^2x=1
\end{math}
\end{document}


or

\documentclass{article}
\usepackage[active,tightpage]{preview}% http://ctan.org/pkg/preview
\begin{document}
% PAGE 1
\begin{preview}
$E=mc^2$
\end{preview}

% PAGE 2
\begin{preview}
$\sin^2x+\cos^2x=1$
\end{preview}
\end{document}


Check out the preview documentation for more options.

-
Great, thanks! This will be extremely helpful. – Manishearth Apr 12 '12 at 6:03
Werner, you don't seem to know the multi option of the standalone class yet. It got introduces with v1.0. It allows for multiple pages as well. – Martin Scharrer Apr 12 '12 at 8:23