5

I am trying to use align and equation in standalone, but I get compiler errors even in the most basic of examples. For example,

\documentclass{standalone}
\usepackage{amsmath}

\begin{document}

\begin{align}
     a = 1 \\
     b=2
\end{align}

\end{document}

Gives

  1 a.tex|10 error| Missing \endgroup inserted.                                                         
  2 a.tex|10 error| Missing } inserted.
  3 a.tex|10 warning| Overfull \hbox (23.61913pt too wide) detected at line 10
  4 a.tex|10 error| LaTeX Error: \begin{document} ended by \end{align}.
  5 a.tex|10 error| Missing $ inserted.
  6 a.tex|10 error| Display math should end with $$.
  7 a.tex|10 error| Extra \endgroup.
  8 a.tex|12 error| Too many }'s.

Similar results with align*, equation, aligned. I as soon as I change the documentclass from standalone to article, it works. I'm sure I am making a silly error here. My platform is Debian, using the TexLive Full package(up to date).

edit: If I move the align block outside the document block, I get no errors(but of course, the pdf is empty)

1
  • 1
    You'll probably need the varwidth option for standalone. Note that it will probably have a lot of horizontal excessive white space
    – daleif
    Jul 16, 2021 at 6:12

1 Answer 1

5

I think you're mis-using, and maybe even abusing, the standalone package. According to the user guide of the standalone package, the main (sole?) purpose of the standalone package is to generate well-contained objects -- often, but not exclusively, pictures -- that can be saved as external files in a suitable file format for subsequent pasting into other documents, e.g., Word and PowerPoint files. It is not designed to generate displayed single-line or multi-line equations via equation or align environments. While it is possible to generate some output by setting the document class option varwidth, it's far from optimal.

If you wish to create a displayed single-line or multi-line equation, you should probably use a aligned environment in inline math mode. E.g.,

\documentclass{standalone}
\usepackage{amsmath}
\begin{document}
$\begin{aligned}
     a &= 1 \\
     b &= 2
\end{aligned}$
\end{document}

compiles fine.

You must log in to answer this question.

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