I have an inline piece of code in my main LaTeX document that I have included using the \lstinline
command:
\lstinline{template<class UIntType, UIntType a, UIntType c, UIntType m> class linear_congruential_engine;}
The resulting output is shown below, which is really not ideal:
What I would like to do is to achieve something a bit more aesthetically appealing, where a newline is introduced before the second class keyword and the next line is indented 3 characters.
Here is a MWE:
\documentclass{article}
\usepackage{listings}
\begin{document}
\lstset{language=C++,
basicstyle=\small\ttfamily,
emptylines=1,
breaklines=true}
\lstset{numbers=left,tabsize=2}
\setcounter{secnumdepth}{1}
\lstMakeShortInline[language=C++,basicstyle=\ttfamily]`
\section{Linear Congruential Generators}
text text text text:
% I want to add a newline after the second class keyword and indent with 3 spaces so that "class linear_congruental_engine" appears indented on the next line
\noindent\lstinline{template<class UIntType, UIntType a, UIntType c, UIntType m> class linear_congruential_engine}
text text text
\end{document}
Here is a related question: Allowing line break at C++ operators ('::', '->', ...) in \lstinline
.tex
file. More info here: meta.tex.stackexchange.com/questions/228/…\lstinline{... m>} \par \lstinline{class ...}
(and you could add spaces before the secondclass
inside\lstinline
, if needed).