The verbatim environment prints its input literally in a monospaced font, including special characters.
Syntax[]
\begin{verbatim} literal-text \end{verbatim}
Restrictions[]
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, 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.
See also[]
- \verb
Packages with additional features[]
- listings and minted (for computer code with syntax highlighting)
- fancyvrb
- verbatimbox
This article includes content from the unofficial LaTeX2e reference manual, which is licensed under the old-style GNU documentation license.