I'm using the listings-package for LaTeX to format source-codes within my document. I can emphasize keywords using the emph-option of the listings package:
\lstset{
emph={nerv},
emphstyle={\color{red}\textbf}
}
\begin{lstlisting}[
frame=trBL,
caption={R-Code (test).},
label={code:R_allee}
]
# comment
square <- function(x) {
x^2
}
nerv = "Str ing "
x <- c(1:100)
y <- square(x)
\end{lstlisting}
This makes the "nerv" withing my source code bold and red. But, I want to highlight the "ing" withing the String "Str ing " using:
\lstset{
emph={ing},
emphstyle={\color{red}\textbf}
}
Unfortunately that does not work. I couldn't figure out what might solve the problem.
Does anyone of you have an idea?


listingsandxcolorin the document preamble. – Werner Aug 12 '11 at 16:19