[Tex/LaTex] typing \end{verbatim}

verbatim

I am preparing a presentation in which I want to display the following as it is

\begin{verbatim}
foo
\end{verbatim}

For this I used

\begin{verbatim}
\begin{verbatim}
foo
\end{verbatim}
\end{verbatim}

But the first \end{verbatim} ends the environment and the second induces error. Can anyone suggest how to do this?

I should appreciate the explanation of the trick and commands suggested.

Best Answer

I don't think that there is any really sensible trick which will work with verbatim directly. I would use another verbatim-like environment from the listings or the fancyvrb package.