Doesn't the verbatim environment work with the standalone class?

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.


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