5

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.

jub0bs
  • 58,916
Salil
  • 53

1 Answers1

9

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

Torbjørn T.
  • 206,688