0

I'm trying to run a LaTeX command within an lstinline from the listings package. I found How can I use LaTeX-commands inside of a listing? which explains about escapechar, and I can get that to work with a regular lstlisting environment, but lstinline seems to ignore it. Am I doing something wrong, is there another way to escape into LaTeX from lstinline, or do inline listings just not support it? The documentation doesn't seem to address it one way or the other.

\documentclass{article}
\usepackage{listings}
\newcommand{\asdf}{command worked}
\begin{document}
\section{lstlisting}
\begin{lstlisting}[escapechar=@]
test: @\asdf@
\end{lstlisting}
\section{lstinline}
\lstinline[escapechar=@]|test: @\asdf@|
\end{document}

Michael Mrozek
  • 16,127
  • 1
  • 23
  • 26

0 Answers0