0

The escape character works inside lstlisting environment but not inside \lstinline

enter image description here

\documentclass[aspectratio=169, xcolor={x11names}, t]{beamer}

\usetheme{Dresden} \usefonttheme{professionalfonts} \renewcommand{\sfdefault}{ppl}

\usepackage[T1]{fontenc} \renewcommand{\encodingdefault}{T1}

\usepackage{listings} \usepackage{matlab-prettifier} % BEGIN_FOLD

\lstdefinestyle{matlab-inline}{ style=Matlab-editor, basicstyle=\linespread{0.8}\mlttfamily\color{DodgerBlue3}, escapechar=", }

% END_FOLD

\lstset{style=matlab-inline}

\begin{document}

\begin{frame}[fragile, environment=frame]

\begin{lstlisting}
text "$e = m c^{2}$"
\end{lstlisting}

\lstinline|text "$e = m c^{2}$"|

\end{frame}

\end{document}

1 Answers1

0

IMHO \lstinline does not support escape characters, because you can end inline code, wherever you want and restart it again after the LaTeX code.

\documentclass[aspectratio=169, xcolor={x11names}, t]{beamer}

\usetheme{Dresden} \usefonttheme{professionalfonts} \renewcommand{\sfdefault}{ppl}

\usepackage[T1]{fontenc} \renewcommand{\encodingdefault}{T1}

\usepackage{listings} \usepackage{matlab-prettifier} % BEGIN_FOLD

\lstdefinestyle{matlab-inline}{ style=Matlab-editor, basicstyle=\linespread{0.8}\mlttfamily\color{DodgerBlue3}, escapechar=", }

% END_FOLD

\lstset{style=matlab-inline}

\begin{document}

\begin{frame}[fragile, environment=frame]

\begin{lstlisting}
text "$e = m c^{2}$"
\end{lstlisting}

\lstinline|text |$\mathcolor{DodgerBlue3}{e = m c^{2}}$

\end{frame}

\end{document}

enter image description here

cabohah
  • 11,455