代码:
\documentclass{article}
\usepackage{parskip}
\usepackage{listings}
\usepackage{textcomp}
\usepackage{xcolor}
\lstset{
basicstyle=\ttfamily,
columns=fullflexible,
keepspaces=true,
upquote=true,
numbers=left,
numberstyle=\ttfamily\color{gray},
language=c,
moredelim=*[is][\itshape]{((:}{:))},
showstringspaces=false,
commentstyle=\color{olive},
keywordstyle=\color{blue},
identifierstyle=\color{violet},
stringstyle=\color{purple},
directivestyle=\color{teal},
}
\begin{document}
Here is the skeleton of the proposed solution:
\begin{lstlisting}
int f(int x)
{
if (x <= 0) {
return 0;
}
if ((x | CONNECT_FLAG) != 0) {
((:statements:))
} else if ((x | DROP_FlAG) != 0) {
((:statements:))
} ((:if else if ladder continues:))
return result;
}
\end{lstlisting}
\end{document}
输出:
问题:
在源代码输出的第 11 行中,if
和else
被语法高亮为关键字。我原本以为它们会用样式高亮显示moredelim
。
我怎样才能防止它们作为关键字被语法高亮显示,而是用样式高亮显示moredelim
?