# How to make a standalone document with one equation?

I was surprised to find that standalone package can not compile a document with an equation:

\documentclass{standalone}
\begin{document}
$$% not working! F(V, T) = E(V) + D(T)$$
\end{document}


Is there an option or some workaround that allows this? The current error is something like:

! Missing $inserted.  in line 4. (The idea of course is that the including (main) document can just \input the standalone without knowing if is going to be an equation or something else) ## 3 Answers The 1.0 version of standalone changed the default option from preview to crop. The latter has several benefits for the use-case the author (me) deemed most common, but forces restricted horizontal mode, which doesn't allow for lists or paragraphs. This causes an error for certain environments which require these. One easy way is to enable the preview mode manually by using it as a class option (\documentclass[preview]{standalone}). You can also reenable this option as default using the standalone.cfg file as described in the manual. However, with preview you get a full line-wide PDF with the equation number (1) at the right, which is not really what you want, is it? \documentclass[preview]{standalone} \begin{document} $$% works now! F(V, T) = E(V) + D(T)$$ \end{document}  Instead it is better to use inline math mode using $ .. $ or $$..$$, which will work with crop and doesn't produce a full line nor a number. You can add \displaystyle if you need it: \documentclass{standalone} \begin{document}$\displaystyle
F(V, T) = E(V) + D(T)
\end{document}  There is also the varwidth option which will wrap the content in a varwidth environment (varwidth package), which is a variable width minipage. This also allows for paragraph breaks etc. and might be better for multi-line equations. varwidth takes an option length argument as text width. • I actually have a math option in mind for standalone, but currently no time to implement it. – Martin Scharrer Mar 31 '12 at 9:33 • With the [preview] option now works! 1) yes, the horizontal mode must have been a dilemma. 2) Answering your question about the numbering can give you ideas on how to implement a math option in standalone: In the final/long document is likely that one wants the numbering (so one is forced to use the equation environment) but in the preview/standalone the numeration doesn't make any sense. So one can add the following to the preamble of the standalone \makeatletter \def\@eqnnum{{\ }} \makeatother Something like this can be handled by your planned math option. – alfC Apr 1 '12 at 21:54 • @MartinScharrer, I would like to see an align equation environment in your planned math option. Perhaps I'm being self-entitled, but hear out my use case: I'm using sympy to output some LaTeX math code and latexmk to refresh a PDF viewer. I'm still starting out with using this kind of environment. My objective is to automate tedious symbolic mathematical manipulations, especially helpful for non-math majors who need to tangle with big math (engineers like me). Or perhaps a full-blown math environment compatibility for standalone? – Kit Nov 15 '13 at 15:43 • @MartinScharrer — Thanks for this great package! Is there any chance that you can add a note about this to the documentation? Currently, search for “math” does not give any results… – jmc Jun 12 '14 at 11:22 standalone uses preview internally. \documentclass{article} \usepackage{amsmath} \usepackage[active,tightpage]{preview} % if you need the equation number, remove the asterix \PreviewEnvironment{equation*} % if you need paddings, adjust the following \PreviewBorder=0pt \begin{document} \begin{equation*} % remove the asterix if you need the equation number F(V, T) = E(V) + D(T) \end{equation*} % remove the asterix if you need the equation number \end{document}  • thanks, but I don't understand what I have to do. Even if I compile your equivalent code (based on preview) the equation is not really rendered as math but as text. – alfC Mar 31 '12 at 5:33 • @alfC: You need to load amsmath. See my edit above. – kiss my armpit Mar 31 '12 at 5:41 • Its work in texlive2011 check it. – Mu30 murugans2katgmail Mar 31 '12 at 6:55 • @S.Murugan: It works with the preview option enabled. This is the case by default with v0.x, but no longer with v1.x as explain in my answer. A "original" TL2011 might still have v0.x, but an updated one has v1.0. – Martin Scharrer Mar 31 '12 at 9:27 • @DamienWalters: standalone only uses preview if the preview option is used, which is no longer the default in v1.0. – Martin Scharrer Mar 31 '12 at 9:29 I tried your code with a slight adjustment. Instead of and I wrapped the equation with dollar symbols like this:  \documentclass{standalone} \begin{document}F(V_{x}, T, \sigma) = E(V_{x}) + D(T,\sigma)\$
\end{document}


This compiles without error for me. It does not provide you with equation numbering though.