【发布时间】:2011-01-04 02:36:36
【问题描述】:
有没有办法可以重置某个字符序列的样式?
我使用listings 包来显示源代码和prebreak 属性来显示转义字符\ 以指示当前行已损坏。问题是有时反斜杠会因为使用的语法突出显示而被着色。
所以我基本上需要类似resetstyle 的语句,如下面的假想示例:
\textbf{Some bold text \resetstyle{not bold, no color} foo bar}
编辑:
以下是我通过lstset 使用的设置:
\lstset{
extendedchars = \true,
inputencoding = utf8,
basicstyle = \scriptsize\ttfamily,
breaklines = true,
breakindent = 10pt,
breakatwhitespace = true,
breakautoindent = true,
prebreak = \\,
frame = leftline,
showtabs = true,
numbers = left,
stepnumber = 2,
numberstyle = \footnotesize,
numbersep = 10pt,
keywordstyle = \color[RGB]{0,0,255},
commentstyle = \itshape\color[RGB]{120,120,120},
stringstyle = \color[rgb]{0.627,0.126,0.941},
emphstyle = {[0]\color[RGB]{236,0,168}},
emphstyle = {[1]\color[RGB]{34,139,34}\underbar},
emphstyle = {[2]\textbf}
}
【问题讨论】: