I want to be able to have inline code (printed in typewriter or something) where I can also use LaTeX commands like \myinlinecode{here comes a backslash: <\textbackslash>}
. So it should be possible to use non-verbatim parts inside the code command.
I read that it should be possible with the listings
package but I could't get it to work. What I tried was:
\documentclass{article}
\usepackage{listings}
\begin{document}
\lstset{escapebegin=x, escapeend=y}
\lstinline|x\textbraceleft y|
\lstset{escapebegin={x}, escapeend={y}}
\lstinline_x\textbraceleft y_
\lstset{escapebegin={\textbackslash}, escapeend={\textbackslash}}
\lstinline_\\textbraceleft \_
\end{document}
Best Answer
The following syntax makes it easier to use "escaped" (or LaTeX) content within
\lstinline
, and might be what you're after. There seems to be no particular need to use specially-assigned characters (likex
andy
) and the usualmathescape
option works (escaping between$
...$
):