I have a text with source code, which I would like to display. I am using pandoc, so I have to use either verbatim or listings environment. Unfortunately, I can't use listings package (due to Cyrillic symbols issue). So, I stuck with verbatim only. But verbatim is unable to make word wrap. I found spverbatim package which is suited to my needs, and now I would like to redefine verbatim enviroment.
1) At first, I've tried to redefine it with let command:
\let\verbatim\spverbatim
But it just doesn't compile, with no errors. Looked like the whole compiling process was hanged up.
2) Then, I've tried to use renewenvironment command:
\renewenvironment{verbatim}{\begin{spverbatim}}{%
\end{spverbatim}\ignorespacesafteren
}
and got an error:
"! TeX capacity exceeded, sorry [save size=80000].
\reserved@a …tim}\edef \@currenvline {\on@line }
\csuse {@begin@spverbatim@…
l.372 \begin{verbatim}"
Is there any way to redefine build in environments like verbatim or I am doing something totally wrong?
Best Answer
You may use the same idea as
spverbatim
; I also added\raggedright
or several overfull boxes would be expected.If you plan to use
verbatim
in lists, a small change is needed (thanks to Christof R for noting):