I am typing up a sentence which contains code, and \verb's ignorance of line breaks is annoying me. This code is very short, and it does not make sense to give it its own line, but I also do not think that it would be good to break it up over multiple lines like texttt would do. Is there a standard way to format code in a LaTeX document which plays nicely with the newlines in a paragraph? Here is an image of the effect to which I am referring:

Asked
Active
Viewed 491 times
2
nosyarg
- 217
1 Answers
1
This is possible with the listings package using its \lstinline (listings equivalent of \verb) with the option breaklines:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{listings}
\lstset{basicstyle=\ttfamily}
\begin{document}
This is my sentence which has some code a little bit later but
\lstinline[breaklines]+RIGHT HERE IN THE LINE+ which is overflowing and does
not seem to want to obey my margin constraints, so I am not entirely sure what
to do with it.
\end{document}
cgnieder
- 66,645

fancyvrb,listingsperhaps? – Jul 01 '16 at 18:21