Latex:重置字体样式
有没有办法重置特定字符序列的样式? 我使用 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}
}
Is there a way I can reset the style of a certain character sequence?
I'm using the listings
package to display source code and the prebreak
property to display a escape character \
to indicate that the current lines was broken. The problem is that sometimes the backslash is colored because of the syntax highlighting used.
So I need basically something like a resetstyle
statement, as in the following imaginary example:
\textbf{Some bold text \resetstyle{not bold, no color} foo bar}
EDIT:
Here are the settings that I'm using via 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}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试将文本放入
mbox
中(未经测试,但适用于数学模式):您将失去在文本内换行的能力,但在这种情况下,这似乎没有问题。
You could try putting the text inside an
mbox
(untested, but works for math mode):You will lose the ability for line breaks inside the text, but in this case that seems to be no problem.