I was surprised to find that standalone
package can not compile a document with an equation:
\documentclass{standalone}
\begin{document}
\begin{equation} % not working!
F(V, T) = E(V) + D(T)
\end{equation}
\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)
Best Answer
The 1.0 version of
standalone
changed the default option frompreview
tocrop
. 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 thestandalone.cfg
file as described in the manual. However, withpreview
you get a full line-wide PDF with the equation number (1) at the right, which is not really what you want, is it?Instead it is better to use inline math mode using
$ .. $
or\( .. \)
, which will work withcrop
and doesn't produce a full line nor a number. You can add\displaystyle
if you need it:There is also the
varwidth
option which will wrap the content in avarwidth
environment (varwidth
package), which is a variable widthminipage
. This also allows for paragraph breaks etc. and might be better for multi-line equations.varwidth
takes an option length argument as text width.