假设我有以下列表样式:
\lstdefinestyle{custCpp}{
language=c++,
keywordstyle={\bfseries}, % keyword color
keywordstyle = [2]{\color{blue}\bfseries},
otherkeywords = {QuadraticException},
morekeywords = [2]{QuadraticException},
commentstyle=\color{gray},
upquote=true,
showstringspaces=false
}
我如何才能避免QuadraticException
在评论中被加粗?
请参阅下面的 MWE:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{textcomp}
\usepackage{listings}
\lstdefinestyle{custCpp}{
language=c++,
keywordstyle={\bfseries}, % keyword color
keywordstyle = [2]{\color{blue}\bfseries},
otherkeywords = {QuadraticException},
morekeywords = [2]{QuadraticException},
commentstyle=\color{gray},
upquote=true,
showstringspaces=false
}
\begin{document}
\begin{lstlisting}[style = custCpp]
// Not styled: try catch else if then
// Styled: QuadraticException
int x = 2;
for (int i = 0; i < x; ++i) {
if (i > 0) {
throw QuadraticException("test working exception class");
}
}
\end{lstlisting}
\end{document}
谢谢您的帮助!