# How can I show a macro as text?

Say I want to make a file which has as text \documentclass{article} I found out I can do it like this:

\documentclass{article}
\begin{document}
\begin{verbatim}
\documentclass{article}
\end{verbatim}
\end{document}


That's fine. But what if I want to have as text \begin{verbatim} and \end{verbatim}?

-

You can use the fancyvrb package. This adds some nice features to the verbatim environment. Among other things it defines an environment Verbatim in which you can write \end{verbatim} since it won't match the \begin{Verbatim}.

\documentclass{article}
\usepackage{fancyvrb}
\begin{document}
\begin{Verbatim}
\begin{verbatim}
text
\end{verbatim}
\end{Verbatim}
\end{document}

-

Define a new verbatim environment with different delimitation strings:

\documentclass{article}

\usepackage{verbatim}
\newenvironment{xverbatim}{\verbatim}{\endverbatim}

\begin{document}

\begin{verbatim}
\documentclass{article}
\end{verbatim}

\begin{xverbatim}
\begin{verbatim}
\documentclass{article}
\end{verbatim}
\end{xverbatim}

\end{document}


Remember also that verbatim environments respect code indentation, so your code

  \begin{verbatim}
\documentclass{article}
\end{verbatim}


will result in four spaces in front of \documentclass{article}.

-