1

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

bad standalone output.

When I run the same code with the standalone class replaced by minimal, I get – without any errors – the expected output, viz:

good minimal output

So I have two issues:

  1. How can I get the standalone class to work with the grammar environment?
  2. How can I get the standalone class 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.

  • i use pdfcrop for 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 get standalone to "behave", i think the answer might be "don't use standalone. i usually use article, and set \pagestyle{empty} to avoid headers and footers. – barbara beeton Feb 27 '16 at 13:42
  • the output from minimal isn't really quite what is "expected". the space following the ::= is too tight. – barbara beeton Feb 27 '16 at 13:53
  • Standalone does not define \textwidth, so always use a minipage for lists and equations. – John Kormylo Feb 27 '16 at 16:22
  • @JohnKormylo: Well, standalone processes the content as a single box not in vertical mode. So for vertical stuff, like paragraphs and equations a minipage or similar is indeed required. For this simply load the class with the varwidth option. – Martin Scharrer Mar 22 '18 at 7:10
  • 1
    You need to use either the preview or the varwidth option if the content is paragraph material. See this answer of mine for further details. – Martin Scharrer Mar 22 '18 at 7:13

Browse other questions tagged or ask your own question.