The verbatim environment is used to display LaTeX commands instead of having them executed.
To display a single command in-line, the \verb||
command can be used.
To display a whole block, we can use \begin{verbatim}
to open the environment and \end{verbatim}
to close it.
But I've come across \verbatim
as well. With that, we can also type \begin{verbatim}
and \end{verbatim}
having them shown on our document and not initiating and ending their environment. The problem is, I still haven't found how to terminate it.
I know there are better ways, and maybe \verbatim
should be never used at all. But I just wanted to understand how it worked to learn more about LaTeX. After invoking it, how can I return to a normal environment where LaTeX code is compiled, a normal font is used and line breaks are automatic?
\begin{verbatim}...\end{verbatim}
is essentially the same as\bgroup\verbatim...\endverbatim\egroup
. That is, matching\verbatim
and\endverbatim
inside a group. Have a look at the documentation to the verbatim environment (usingtexdoc verbatim
on a unix-like system), to find out how to use it inside other environments\endverbatim
.\endverbatim
gets written. Not even with\bgroup
and\egroup
it has any effect. Thanks to you I'm learning a lot about it, but my quick question still stands: even if I simply shouldn't, after I simply type\verbatim
and nothing else, how can I close the environment?