Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 24 down vote accepted

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.

share|improve this answer
    
Great, thanks! This will be extremely helpful. –  Manishearth Apr 12 '12 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. –  Martin Scharrer Apr 12 '12 at 8:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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