I pasted some code into a document in a Verbatim
environment from fancyvrb
. Because it is within two nested enumerate
environments, the code is indented quite far over. As a result, one long line of code extends off the page. The quickest fix that I could think of was to place a \hspace
command with a negative argument just before the Verbatim
environment in order to shift the whole Verbatim
environment over to the left a few cm. However, this had no effect. Can someone suggest a solution please? See MWE below.
\documentclass{article}
\usepackage{fancyvrb}
\begin{document}
\begin{enumerate}
\item First item
\begin{enumerate}
\item First sub-item
\hspace{-5cm}\begin{Verbatim}[fontsize=\tiny]
This line of code is nice and short and fits nicely on the page.
This line of code is very long and does not fit onto the page!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!The End
\end{Verbatim}
\end{enumerate}
\end{enumerate}
\end{document}
Best Answer
Here's a solution with the
verbatimbox
package. Note that this first solution will not break the verbatim across page boundaries.For a solution that can break the verbatim across page boundaries, with the
\hspace
: