16

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??

1

1 Answer 1

24

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

enter image description here

\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:

enter image description here

\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.

2
  • Great, thanks! This will be extremely helpful. Commented Apr 12, 2012 at 6:03
  • 3
    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. Commented Apr 12, 2012 at 8:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .