1

I would like to insert a custom symbol on LaTeX listings:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\usepackage{stix}
\lstset{language=c,escapeinside={(*}{*)}}

\newcommand{\spc}{$\mathvisiblespace$}

\begin{document}

\lstinline{(*\spc*)} % Does not work

% This works
\begin{lstlisting} 
  (*\spc*)
\end{lstlisting}

\end{document}

Unfortunately, the command \spc is included literally. Is there a way to allow commands in \lstinline?

This question shows how to use escapeinside, but it does not work in my example. *\spc* is inserted literally.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.