How can I place \lstinline code inside commands like \chapter, \section, \subsection, etc.?
Or it's a bad or tasteless practice?
How can I place \lstinline code inside commands like \chapter, \section, \subsection, etc.?
Or it's a bad or tasteless practice?
You can, as long as you \protect moving arguments:
\documentclass{report}
\usepackage{listings}
\lstset{
basicstyle=\ttfamily
}
\begin{document}
\tableofcontents
\chapter{The \protect\lstinline!if! command}
\section{The \protect\lstinline!while! command}
\subsection[More commands]{The \lstinline!end! command}
\end{document}
\lstinline code inside \item description AND automatically add the \item content to a glossaries entry.
– Alberto López
Oct 30 '21 at 22:36
%#&, etc.
– Alberto López
Nov 18 '21 at 21:39
\lstinline|MOV A, #12H| in the choice items of this https://tex.stackexchange.com/a/141643/24012, the result is that I see two ## in the rendered output. Luckily, I find the answer here. I just try to use this \protect\lstinline|MOV A, \#12H|, and the problem is gone, I mean the rendered text is correct. But I see this is still a bit complex, any better solutions? BTW, I think Werner's code mentioned here https://pastebin.com/raw/DDWm7FRP should be added to the answer.
– ollydbg23
Feb 09 '23 at 09:05
whilekeyword. – Alberto López Oct 29 '21 at 21:53\protect\lstinline!...!since the argument of the titles are moving and therefore fragile. – Werner Oct 29 '21 at 22:24