I am using the minted
package for typesetting matlab source code.
There is an escapeinside
option for the listing
environment provided by minted to escape to regular TeX commands.
However, this does not work on comment lines. Here is a MWE
illustrating the problem.
\documentclass{article}
\usepackage{minted}
\usepackage{amsmath}
\begin{document}
The code for computing mass-energy relationship is given in listing~\ref{listing:massenergy}.
\begin{equation}\label{eq:massenergy}
e = mc^2
\end{equation}
\begin{listing}
\begin{minted}[mathescape,autogobble,escapeinside=||,frame=single]{matlab}
e = m*c^2; % |see equation~\eqref{eq:massenergy}| does not work!
|see equation~\eqref{eq:massenergy}| works
\end{minted}
\caption{Mass-Energy source code listing}
\label{listing:massenergy}
\end{listing}
\end{document}
Here is the output produced
How can one escape to TeX/LaTeX inside minted comment lines?
escapeinside
says “Escaping does not work inside strings and comments (for comments, there istexcomments
).”