I noticed that LaTeX's verbatim
environment doesn't do word wrapping. How do I get it to word wrap verbatim text?
Word wrap is the additional feature of most text editors, word processors, and web browsers, of breaking lines between words rather than within words, where possible.
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.
Essentially you can’t.
But the listings
package, whose actual purpose is to format source code, does support word wrapping. So maybe you can use the listings
environment instead.
Here is the full example for the listings
package:
\documentclass{report}
\usepackage{listings}
\lstset{breaklines=true}
\begin{document}
\begin{lstlisting}
some text here
\end{lstlisting}
\end{document}
You might also add the following definitions for line numbering and _background_color:
\lstset{numbers=left, numberstyle=\scriptsize\ttfamily, numbersep=10pt, captionpos=b}
\lstset{backgroundcolor=\color{gray-5}}
\lstset{basicstyle=\small\ttfamily}
\lstset{framesep=4pt}
Add this for inline code:
\newcommand{\inlineCode}{\lstinline[basicstyle=\normalsize\ttfamily]}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With