[Tex/LaTex] How to have a verbatim text in specific sized box

boxesverbatim

I am trying to typset the following

\resizebox{0.95\textwidth}{!}{%
 \begin{verbatim}
  require( "lattice" )
  require( "grid" )
 \end{verbatim}
}

I have a lot more to add to this box, and it needs to be typset verbatim, but it gives me an error. Am i doing something wrong.

Best Answer

You can not use verbatim in the argument to another command.

\documentclass{article}
 \usepackage{graphicx}
\begin{document}
\newsavebox\myv

\begin{lrbox}{\myv}\begin{minipage}{\textwidth}
\begin{verbatim}
...
\end{verbatim}
\end{minipage}\end{lrbox}

\resizebox{0.95\textwidth}{!}{\usebox\myv}
\end{document}