Word wrap in verbatim environments [closed]
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this questionI noticed t开发者_高级运维hat LaTeX's verbatim
environment doesn't do word wrapping. How do I get it to word wrap verbatim text?
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]}
精彩评论