
article
我在模組中使用帶有文檔類別和“定理(AMS)”的 LyX 2.0.5 。我想知道是否可以使不同環境的標題以不同的顏色突出顯示(在突出顯示標記的意義上“突出顯示”。即,具有彩色背景,不更改字體顏色) 。例如,在Theorem
環境中的單字定理12.1將以紅色突出顯示排版,在Definition
環境中的文字定義5.9將以黃色突出顯示等進行排版。
我猜需要更改模組?
答案1
(注意:此解決方案的某些部分不是最佳的,我知道這一點,但我稍後必須修復它。當我有時間改進時,我將刪除此註釋。)
您可以更改文件theorems-ams.module
並theorems-ams.inc
,或更好地建立副本,如我的回答中所述如何讓「聲明」環境看起來像是「定理」環境?
在 中theorems-ams.module
,新增xcolor
到所需的套件中。即它說的地方
Requires amsmath,amsthm
將此編輯為
Requires amsmath,amsthm,xcolor
(這一點未經測試,但我認為它會起作用。)
在 中theorems-ams.inc
,找到要變更的樣式,例如定義定理外觀的區塊以 開頭Style Theorem
。
在Style
區塊中有一個子區塊Preamble
,預設看起來像
Preamble
\theoremstyle{plain}
\newtheorem{thm}{\protect\theoremname}
EndPreamble
使用取自的程式碼艾格格的回答amsthm 環境和 colorbox,編輯此內容以閱讀
Preamble
\newtheoremstyle{Coloredtheo}%
{3pt} %Space above
{3pt} %Space below
{} %Body font
{} %Indent amount
{\bfseries} %Theorem head font
{} %Punctuation after theorem head
{0.25em} %Space after theorem head
{\colorbox{red}{\color{black}\thmname{#1}%
\thmnumber{\@ifnotempty{#1}{ }\@upn{#2}}}%
\thmnote{ {--- \the\thm@notefont#3.}}%
} %Theorem head spec
\theoremstyle{Coloredtheo}
\newtheorem{thm}{\protect\theoremname}
EndPreamble
請注意,這不會變更 LyX 中的視圖,只會變更 PDF 中的視圖。對 進行類似的操作Definition
,但對 使用不同的名稱\newtheoremstyle
。背景顏色由\colorbox
此處的第一個參數設定red
。
對於單一文檔,您可以使用文檔 --> 設定下的本機佈局。將整個Style
區塊新增至本機佈局。您可能還需要包含\usepackage{xcolor}
到該Preamble
區塊中。