I'm writing a computer science paper with LaTeX and have a lot of inline code. Now, when this code is followed by a comma and is at the end of line, the line break is inserted before the comma, which is wrong and looks weird.
Here's an example:
This is normal text with some
inlined code
,more inlined code
, andeven more inlined code
.
Basically, the corresponding LaTeX code is (although I'm having problems reproducing the issue in this MWE):
\documentclass{minimal}
\usepackage{listings}
\begin{document}
This is normal text with some \lstinline{inlined code},
\lstinline{more inlined code}, and \lstinline{even more inlined code}.
\end{document}
How can I avoid the line break between the code and the comma?
I found that putting \mbox
around the comma and \lstinline
macro works, but this feels not right.
Are there better solutions?
If the problem is due to settings in my universities .sty
or .cls
files, is there a way I could quickly find the offending option? … That is, without commenting most of it and then re-introduce every option one by one.
edit
Finally managed to whip up a short working example:
\documentclass[11pt]{book}
\usepackage{listings}
\lstset{
basicstyle=\ttfamily\footnotesize,
breaklines=true
}
\begin{document}
Bacon ipsum dolor sit amet ball tip shankle i Nrtdy uses \lstinline{System.LongerCode}, whereas Uiae uses \lstinline{System.OtherCode}.
\end{document}
Removing breaklines=true
seems like to avoid the problem. This in unfortunate, since I need automatic line breaks in listings in other places.
Is there a sensible fix?
\lstinline
code. I'm afraid it depends on the.cls
or.sty
files you're using.\lst