8

I have the following code, which is as minimal as it could possibly be ( standalone 2015/07/15 v1.2):

\documentclass{standalone}

\begin{document}
\begin{verbatim}
Ciao
\end{verbatim}
\end{document}

And I get the error:

! LaTeX Error: Something's wrong--perhaps a missing \item.

If I replace the standalone class with another class, e.g. article, everything works fine.

Where's the issue?

11

Try

\documentclass[preview]{standalone}% <-- added option "preview"

\begin{document}
\begin{verbatim}
Ciao
\end{verbatim}
\end{document}

This should work ...

Edit: Also work with option varwidth. Both options enable to show verbatim environments and as well as displayed math. This is not special described in standalone manual, but seems that for text elements/environments, which normally occupy whole text line, it is obligatory to select appropriate standalone's options.

|improve this answer|||||
  • 2
    Care to explain why is an optional argument mandatory? – Matsmath May 5 '16 at 7:33
  • @Matsmath, done. – Zarko May 5 '16 at 8:08
2

The verbatimbox package allows inline verbatim environments that work directly with the standalone class. Once the box is created with the verbbox environment, it is displayed with \theverbbox.

\documentclass{standalone}
\usepackage{verbatimbox}
\begin{document}
\begin{verbbox}
Ciao
\end{verbbox}
\theverbbox
\end{document}

enter image description here

Example 2 (longer code and optional argument):

\documentclass{standalone}
\usepackage{verbatimbox}
\begin{document}
\begin{verbbox}[\scshape]
This is code line 1
Blah
Blah-blah
Finis
\end{verbbox}
\theverbbox
\end{document}

enter image description here

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.