Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
1  
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
add comment

1 Answer

up vote 7 down vote accepted

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

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.