# Trouble Displaying Listings Package

I will show the settings of the listings package, like this MWE:

\documentclass{article}
\usepackage{xcolor}
\usepackage{listings}
\lstset{
backgroundcolor=\color{yellow!10},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
deletekeywords={...},
escapeinside={\%*}{*)},
frame=leftline,
keepspaces=true,
keywordstyle=\color{blue},
language={[LaTeX]{TeX}},
numbers=left,
numbersep=5pt,
numberstyle=\ttfamily\color{blue},
rulecolor=\color{blue},
showlines=true,
showspaces=false,
showstringspaces=false,
showtabs=false,
stepnumber=1,
stringstyle=\color{blue},
tabsize=2,
title=\lstname
}
\begin{document}
\begin{lstlisting}[caption=Listings Package Setting]
\lstset{
backgroundcolor=\color{yellow!10},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
deletekeywords={...},
escapeinside={\%*}{*)},
frame=leftline,
keepspaces=true,
keywordstyle=\color{blue},
language={[LaTeX]{TeX}},
numbers=left,
numbersep=5pt,
numberstyle=\ttfamily\color{blue},
rulecolor=\color{blue},
showlines=true,
showspaces=false,
showstringspaces=false,
showtabs=false,
stepnumber=1,
stringstyle=\color{blue},
tabsize=2,
title=\lstname
}
\end{lstlisting}
\end{document}


but does not show what I want

-
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. –  Jubobs Jun 4 at 13:48

This is because you're duplicating your settings as part of a listing to which all the settings apply. As such, not only do you define the listing to escape inside some set of elements, but you also supply those elements.

I would just temporarily disable the escapeinside key-value for the listing that contains your settings:

\begin{lstlisting}[caption=Listings Package Setting, escapeinside={}{}]


This provides the output:

-
Solved! Thanks, @Werner! –  Edy Jo Jun 1 at 7:17

It's because of escapeinside it will create area to you that's not in the listing area, you can write LaTeX code there for example

\documentclass{article}
\usepackage{xcolor}
\usepackage{listings}
\lstset{
backgroundcolor=\color{yellow!10},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
deletekeywords={...},
escapeinside={\%*}{*)},
frame=leftline,
keepspaces=true,
keywordstyle=\color{blue},
language={[LaTeX]{TeX}},
numbers=left,
numbersep=5pt,
numberstyle=\ttfamily\color{blue},
rulecolor=\color{blue},
showlines=true,
showspaces=false,
showstringspaces=false,
showtabs=false,
stepnumber=1,
stringstyle=\color{blue},
tabsize=2,
title=\lstname
}
\begin{document}

\begin{lstlisting}[caption=Listings Package Setting]
\lstset
backgroundcolor=\color{yellow!10},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
deletekeywords={...},
escapeinside={%* book,article are keywords but here!!\\
I can use \LaTeX codes here like $\Sigma$
*)},
frame=leftline,
keepspaces=true,
keywordstyle=\color{blue},
language={[LaTeX]{TeX}},
numbers=left,
numbersep=5pt,
numberstyle=\ttfamily\color{blue},
rulecolor=\color{blue},
showlines=true,
showspaces=false,
showstringspaces=false,
showtabs=false,
stepnumber=1,
stringstyle=\color{blue},
tabsize=2,
title=\lstname

\end{lstlisting}
\end{document}


so the code between escapeinside %*[Code here]*) will be LaTeX code and when you copy past it the }{ would cause an error because its an error in LaTeX document.

If you want have the exact text use this escapeinside=%*\{\textbackslash \%\textasteriskcentered\}\{\textasteriskcentered)\}*)

-
Thank you, @Karo! –  Edy Jo Jun 1 at 7:38