4

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}
}
4

2 回答 2

0

您可以尝试将文本放入mbox(未经测试,但适用于数学模式):

\textbf{Some bold text \mbox{not bold, no color} foo bar}

您将失去在文本内换行的能力,但在这种情况下,这似乎没有问题。

于 2010-01-12T09:32:36.610 回答
0
\def\resetstyle#1{{\normalsize\rm\color[rgb]{0,0,0}\noindent#1}}
于 2010-01-12T09:34:01.367 回答