# minipage with verbatim package doesn't compile

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?

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

\usepackage{verbatim}

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.