Next: verse, Previous: titlepage, Up: Environments [Contents][Index]
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 appear
there. (But 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.
• \verb: | The macro form of the verbatim environment.
|