# Does the standalone package not play well with the exam class?

Here is a very minimal example:

\documentclass[class=exam]{standalone}

\begin{document}

\begin{questions}

\question
Text.

\end{questions}

\end{document}


It produces the error:

! 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.8


But run with \documentclass{exam} it works correctly.

• My understanding was that by passing the option "class=exam" to standalone, it bases the standalone document on the exam class. From the standalone documentation: "Specifies the underlying class which is loaded by the standalone class." – DanielGr Oct 11 '17 at 0:59
• Adding [varwidth=true] works. It has to do with things like \textwidth being undefined. – John Kormylo Oct 11 '17 at 12:52
• Thanks @JohnKormylo! It seems that [crop=false] also achieves this. – DanielGr Oct 11 '17 at 14:15

The problem here is that standalone is targeted at single diagramms which are single boxes, not paragraphs. Therefore the content is processed in restricted horizontal mode which doesn't allow vertical content like text lines or lists. If you need to add text you need enable paragraph processing again.

This can be done by either switching from the normal crop mode to preview which handles the content in vertical mode OR by adding the varwidth option which wraps the content into a varwidth environment (from the varwidth package) before. This way the list is turned into a box.

This has nothing to do with the exam class, but by the fact, that the questions environment is implemented as a list or similar.