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.

nowox
  • 1,375
  • 2
    escapechar and escapeinside don't work in \lstinline, only in the environment, but you can use mathescape: https://tex.stackexchange.com/questions/43526/escaping-in-lstinline – Ulrike Fischer Aug 05 '19 at 07:37

0 Answers0