【问题标题】:Latex: reset font styleLatex:重置字体样式
【发布时间】: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}
}

【问题讨论】:

    标签: latex reset listings


    【解决方案1】:
    \def\resetstyle#1{{\normalsize\rm\color[rgb]{0,0,0}\noindent#1}}
    

    【讨论】:

    • 不幸的是,它对我不起作用,出现! Improper discretionary list. 之类的错误。也许是因为它与列表样式发生冲突?
    • 可能是。我需要更复杂的样本来找出问题。
    【解决方案2】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2017-01-29
      • 2016-12-22
      • 1970-01-01
      • 1970-01-01
      • 2018-08-20
      • 1970-01-01
      • 2016-09-26
      • 2015-09-23
      • 2014-06-23
      相关资源
      最近更新 更多