lstlisting代码是蓝色而不是黑色 - keywordstyle接管?

时间:2018-05-23 10:36:42

标签: colors lstlisting

当使用lstlisting和某些参数时,(大多数)代码变为蓝色,即使它应该只是关键字和标识符,而其余的应该是黑色。为了更好地衡量,文档中的其余文本是黑色的: - )

最好关键字也应该是粗体,但我发现可能是字体问题,但我无法弄清楚如何更改lstlisting字体而不更改整个文档的字体。

谢谢你的时间!

\lstset{language={[Sharp]C},
basicstyle=\color{black}\ttfamily\scriptsize,
numbers=left,
numberstyle=\tiny,
numbersep=3pt,
tabsize=1,
extendedchars=true,
breaklines=true,
keepspaces=true,
showspaces=false,
showtabs=false,
xleftmargin=5pt,
framexleftmargin=5pt,
framexrightmargin=5pt,
framexbottommargin=4pt,

morecomment=[l]{//}, %use comment-line-style!
morecomment=[s]{/*}{*/}, %for multiline comments
showstringspaces=false,
commentstyle=\color{black},
keywordstyle=\color{blue}\bfseries,
identifierstyle=\color{blue}\bfseries,
backgroundcolor=\color{almostwhite},
}

以下是已编译PDF中的代码示例:

Blue Code

1 个答案:

答案 0 :(得分:1)

我不知道问题是否已经解决,但似乎您的语言C Sharp不是预定义的语言here p.12选项卡1。

您可以使用lstdefinelanguage来创建自己的语言,请参见here以获取其工作方式示例

相关问题