I have a little problem in my settings. I cannot locate the error and need some additional eyes to tell me where I should look. I use listing to show my c++ code but when I try to add additional keywords they are not highlighted. Here's the setting:
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{dred}{rgb}{0.545,0,0}
\definecolor{dblue}{rgb}{0,0,0.545}
\definecolor{lgrey}{rgb}{0.9,0.9,0.9}
\definecolor{gray}{rgb}{0.4,0.4,0.4}
\definecolor{darkblue}{rgb}{0.0,0.0,0.6}
\lstset{
backgroundcolor=\color{lgrey},
basicstyle=\footnotesize \ttfamily \color{black} \bfseries,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
commentstyle=\color{dkgreen},
deletekeywords={...},
escapeinside={\%*}{*)},
frame=single,
keywordstyle=\color{purple},
morekeywords={BRIEFDescriptorConfig,string,TiXmlNode,DetectorDescriptorConfigContainer,istringstream,cerr,exit},
identifierstyle=\color{black},
stringstyle=\color{blue},
language=C++,
numbers=right,
numbersep=5pt,
numberstyle=\tiny\color{black},
rulecolor=\color{black},
showspaces=false,
showstringspaces=false,
showtabs=false,
stepnumber=1,
tabsize=5,
title=\lstname,
}
So nothing special, I guess. Here is an minimal-example using listing:
\begin{lstlisting}[language={C++},caption={Caption}]
void XMLDetDecConfigReader::handleDescriptors(DetectorDescriptorConfigContainer* configContainer, TiXmlNode* descriptorsNode);
\end{lstlisting}
I don't want to use any other packages but to solve this highlighting-problem.
Thank you for your help.
Best Answer
Output
I would heed Sašo Živanović's advice about defining your own
C++
dialect if you are going to typeset other codes in other languages in your document apart fromC++
. If not, then writelanguage=C++,
beforekeywordstyle=\color{purple},
in your\lstset
, then omit thelanguage={C++}
from your optional argument. You do this also for your own flavor ofC++
highlighting via the\lstdefinelanguage
command.Here is a minimal working example (MWE) completed from your code snippets. (Please post MWEs next time.)
Code