[Tex/LaTex] How to use multiple declarations (\textbf, \emph) in listings’ emphstyle

emphasislistings

How do I provide multiple emphstyles with the listings package?

\begin{lstlisting}[emph={if,for},emphstyle={\textbf\emph}]
if something
end if
\end{lstlisting}

Both styles above (\emph and \textbf} don't get applied. If I use only one style, it works.

Best Answer

I guess you want it to be italic and boldshape. By using \itshape and \bfseries instead it works.

\documentclass{article}
\usepackage{listings}
\begin{document}
\begin{lstlisting}[emph={if,for},emphstyle={\bfseries\itshape}]
if something
end if
\end{lstlisting}
\end{document}

enter image description here

Related Question