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\verbatimand\endverbatiminside a group. Have a look at the documentation to the verbatim environment (usingtexdoc verbatimon a unix-like system), to find out how to use it inside other environments – May 28 '15 at 09:39\endverbatim. – Ulrike Fischer May 28 '15 at 09:48\endverbatimgets written. Not even with\bgroupand\egroupit 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\verbatimand nothing else, how can I close the environment? – Jeffrey Lebowski May 28 '15 at 09:51\newcommand\foowill not generate\endfoo. It's the\end{foo}which checks if\endfooexists, and if it doesn't just inserts an\endgroupwithout worrying. – Manuel May 28 '15 at 11:12