1

正如您在我的算法中看到的那样,有些单词以粗体突出显示,但我不希望变量部分中的单词以粗体显示,因为它们只是注释。但是,如果我在谈论代码,我希望这些词是粗体的,就像upon标签中定义的那样。我的算法是用lstlisting.

我有粗体字,因为我在这里定义了 [2]。

当我不想要粗体时如何删除粗体字?

算法片段

[2] 粗体字

\lstdefinelanguage{distributed}{
morekeywords={Implements,Uses,upon,event,procedure,returns,return,trigger,while,exists,such,that,do,for,forall,from,to,all,if,elif,then,else,end,endif,endwhile,and,or,break},
morekeywords={Require,Ensure,constants,variables,abort,note},
}
4

2 回答 2

1

我认为您应该在语言定义中定义“morecomment”,以便以正确的方式打印评论。也可以看看

http://texdoc.net/texmf-dist/doc/latex/listings/listings.pdf

第 22 页。

于 2015-12-01T09:24:59.853 回答
0

这是我的解决方案:

\lstdefinelanguage{distributed}{
     morekeywords={Implements,Uses,upon,event,procedure,returns,return,trigger,while,exists,such,that,do,for,forall,from,to,all,if,elif,then,else,end,endif,endwhile,and,or,break},
     morekeywords={Require,Ensure,constants,variables,abort,note},
     morecomment=[l]{--},
     morecomment=[l]{//},  % l is for line comment
     morecomment=[n]{(*}{*)},
     morecomment=[is]{/*}{*/},  % s is for start and end delimiter
     morestring=[b]",
     morestring=[d]'
 }
于 2015-12-03T10:55:14.273 回答