8

This is my code:

\usepackage{verbatim}
\newenvironment{listing}
{\begin{minipage}{\linewidth}\verbatim}
{\endverbatim\end{minipage}}

However, it doesn't compile:

Runaway argument?
! File ended while scanning use of \next.
<inserted text>
                \par

What is wrong?

1
  • 1
    You have also to use \minipage and \endminipage instead of \begin{minipage} and \end{minipage} respectlvely. – egreg Jul 19 '15 at 21:29
9

You have to do

\usepackage{verbatim}

\newenvironment{listing}
{\minipage{\linewidth}\verbatim}
{\endverbatim\endminipage}

There's almost the same example on page 3 of the package documentation, see the definition of the fred environment.

Note that \begin{minipage} executes (among other things) \minipage and similarly \end{minipage} executes \endminipage.

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.