# listings 'escapeinside'-option is not working for me

this is my first question here. I'm not exaclty new to LaTeX, but to be honest I've never really gotten too much into it.

So here's my problem:

I have this minimal example:

\documentclass{scrreprt}

% Quellcode
\usepackage{listings} % für Formatierung in Quelltexten
\lstset{
}

\begin{document}

\chapter{some chapter}

\section{some section}
some text \lstinline|some code (*@ \textbf{TRYING TO ESCAPE HERE} @*) some more code|

\end{document}


What I get in my pdf-file is this:

I guess you can see I'm trying to escape the \lstinline command to insert a basic LaTeX one but it's not working for me. I'm referring to the escapeinside-option from the listings-manual section 4.14.

I hope I've stuck to all the standards with my post. Please let me know if any further information about package versions and what not is required. Any help will be very much appreciated!

• Aug 22 '14 at 16:32

Although not explicitly stated in the documentation I have found that the escaping only works in listings using the lstlisting environment, not within lstinline. See this:

\documentclass{scrreprt}

% Quellcode
\usepackage{listings} % für Formatierung in Quelltexten
\lstset{
}

\begin{document}

\chapter{some chapter}

\section{some section}
some text \lstinline|some code (*@ \textbf{TRYING TO ESCAPE HERE} @*) some more code|

A new paragraph and a listing:
\begin{lstlisting}
some code (*@ \textbf{TRYING TO ESCAPE HERE} @*) some more code
\end{lstlisting}
\end{document}


And actually thinking about it, within a lstinline escaping seems to make little sense - you could just use \lstinline|some code| \textbf{TRYING TO ESCAPE HERE} \lstinline|some more code| in your example.

• It would make sense! Some formatting rules (e.g., font size) do apply to escaped latex code within listings. Splitting up into two inline listings with some normal text in between does not take that into account (I have a real-world example at hand currently :/) Nov 8 '15 at 1:01