verbatim
Synopsis:
\begin{verbatim} literal-text \end{verbatim}
A paragraph-making environment in which LaTeX produces as output
exactly what you type as input. For instance inside literal-text
the backslash \
character does not start commands, it
produces a printed ‘\’, and carriage returns and blanks are taken
literally. The output appears in a monospaced typewriter-like font
(\tt
).
\begin{verbatim} Symbol swearing: %&$#?!. \end{verbatim}
The only restriction on literal-text
is that it cannot include
the string \end{verbatim}
.
You cannot use the verbatim environment in the argument to macros, for
instance in the argument to a \section
. This is not the same as
commands being fragile (see \protect
), instead it just cannot work,
as the verbatim
environment changes the catcode regime before
processing its contents, and restore it immediately afterward,
nevertheless with a macro argument the content of the argument has
already be converted to a token list along the catcode regime in effect
when the macro was called. However, the cprotect
package can
help with this.
One common use of verbatim input is to typeset computer code. There are
packages that are an improvement the verbatim
environment. For
instance, one improvement is to allow the verbatim inclusion of external
files, or parts of those files. Such packages include listings
,
and minted
.
A package that provides many more options for verbatim environments is
fancyvrb
. Another is verbatimbox
.
For a list of all the relevant packages, see CTAN (see CTAN: The Comprehensive TeX Archive Network).