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

\begin{equation} % not working!
F(V, T) = E(V) + D(T)

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 3


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?

\begin{equation} % works now!
F(V, T) = E(V) + D(T)

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:

F(V, T) = E(V) + D(T)

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.

  • 4
    I actually have a math option in mind for standalone, but currently no time to implement it. Commented Mar 31, 2012 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
    Commented Apr 1, 2012 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
    Commented Nov 15, 2013 at 15:43
  • 2
    @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
    Commented Jun 12, 2014 at 11:22
  • @MartinScharrer Is there any way to output to png with math? See my question.
    – mcp
    Commented Sep 10, 2020 at 16:16

standalone uses preview internally.


% if you need the equation number, remove the asterix

% if you need paddings, adjust the following

\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
  • 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
    Commented Mar 31, 2012 at 5:33
  • @alfC: You need to load amsmath. See my edit above. Commented Mar 31, 2012 at 5:41
  • Its work in texlive2011 check it. Commented Mar 31, 2012 at 6:55
  • 1
    @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. Commented Mar 31, 2012 at 9:27
  • @DamienWalters: standalone only uses preview if the preview option is used, which is no longer the default in v1.0. Commented Mar 31, 2012 at 9:29

I tried your code with a slight adjustment. Instead of \begin{equation} and \end{equation} I wrapped the equation with dollar symbols like this:

$F(V_{x}, T, \sigma) = E(V_{x}) + D(T,\sigma)$

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

You must log in to answer this question.

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