I use TeX Live 2015.
Update. I just found out that using the preview option to the class solves the problem, yet only crops the content vertically, not horizontally.
I want to use a grammar environment from the syntax package within a standalone documentclass (for producing small images). But when I run pdflatex on
\documentclass{standalone}
\usepackage{syntax}
\begin{document}
\begin{grammar}
<A> ::= `Z'
\end{grammar}
\end{document}
I get the following errors:
! LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.6 \end{grammar}
?
! LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.6 \end{grammar}
?
Of course, I can skip through them, but then my output becomes
When I run the same code with the standalone class replaced by minimal, I get – without any errors – the expected output, viz:
So I have two issues:
- How can I get the
standaloneclass to work with thegrammarenvironment? - How can I get the
standaloneclass to correctly compile certain symbols like ‘<’ and ‘>’?
By the way. I realise I am misusing the standalone class. My use case is: Create small pictures out of latex code to include them on a website (where I don’t want to use MathJax). If you know of a good way to accomplish that, I’d be happy to give that a try instead.


pdfcropfor this, and gave the "formula" at http://tex.stackexchange.com/a/247690/579. there are other good answers to that question, so you might want to take a look. regarding your second question, how to getstandaloneto "behave", i think the answer might be "don't usestandalone. i usually usearticle, and set\pagestyle{empty}to avoid headers and footers. – barbara beeton Feb 27 '16 at 13:42minimalisn't really quite what is "expected". the space following the::=is too tight. – barbara beeton Feb 27 '16 at 13:53standaloneprocesses the content as a single box not in vertical mode. So for vertical stuff, like paragraphs and equations aminipageor similar is indeed required. For this simply load the class with thevarwidthoption. – Martin Scharrer Mar 22 '18 at 07:10previewor thevarwidthoption if the content is paragraph material. See this answer of mine for further details. – Martin Scharrer Mar 22 '18 at 07:13