# How can I use multiple declarations (\textbf, \emph) in listings' emphstyle?

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.

-
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can use backticks  to mark your inline code‌​. You can also highlight the code and click the "code" button (with "{}" on it). –  Torbjørn T. Nov 20 '11 at 0:44

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}


-
Thanks. I wonder from where they expect you to learn that. –  Salil Nov 20 '11 at 0:48
@Salil: Experience :) Perhaps this is a start: Is there a difference between \textit and \itshape? The motivation here is that \textbf, \textit and \textsf are local macros that take arguments, while \bfseries, \itshape and \sffamily` are switches. –  Werner Nov 20 '11 at 1:44