2010-01-12 69 views
3

有沒有一種方法可以重置某個字符序列的樣式? 我使用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} 
} 

回答

0

您可以嘗試將文字放入mbox(未經測試,但適用於數學模式):

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

您將失去文本內換行符的能力,但在這種情況下似乎沒有問題。

+0

不起作用:/。實際上沒有任何反應。 – watain 2010-01-12 09:44:20

0
\def\resetstyle#1{{\normalsize\rm\color[rgb]{0,0,0}\noindent#1}} 
+0

不幸的是,我得到的錯誤像'!不適當的酌情清單.'​​。也許這是因爲它與列表樣式一起發生衝突? – watain 2010-01-12 09:44:50

+0

可能。我需要更復雜的樣本來找出問題。 – 2010-01-12 12:18:20

+0

我加了我的'lstset'設置。你需要更多信息? – watain 2010-01-12 12:44:31