如果原始海报(或其他任何人)可能对突出显示在打开/关闭 LaTeX 代码之间的文本感兴趣,下面是一些示例。活性成分是一个正则表达式(\\(.\\|\n\\)+?\\)
,它可能是其他类似的东西,但需要有效地做同样的事情。以下示例设置为突出显示出现在引号之间的文本,LaTeX 艺术家皱眉,一个粗体命令,一个下划线和一个双下划线,使用名为ulem
, bold 和 underline 的 tex 包,我投入了一个开始/结束文档示例所以原始海报(或其他任何人)可以结合示例制作他/她自己的。
注意:随着定义变得更加复杂并且倾向于与其他定义重叠,它们出现的顺序可能很关键——即,一个定义可能胜过另一个。
(font-lock-add-keywords 'latex-mode (list
(list (concat "\\(\"\\)\\(\\(.\\|\n\\)+?\\)\\(\"\\)")
'(1 lawlist-super-orange t)
'(2 lawlist-super-cyan t)
'(4 lawlist-super-orange t))
(list (concat "\\(\{\\)\\(\\\\bf\\)\\(\\(.\\|\n\\)+?\\)\\(\}\\)")
'(1 lawlist-regular t)
'(2 lawlist-purple t)
'(3 lawlist-bold t)
'(5 lawlist-regular t))
(list (concat "\\(\\\\uline\\|\\\\uuline\\)\\(\{\\)\\(\\(.\\|\n\\)+?\\)\\(\}\\)")
'(1 lawlist-green t)
'(2 lawlist-regular t)
'(3 lawlist-underline t)
'(5 lawlist-regular t))
(list (concat "\\(\{\\)\\(\\\\bf\\)\\(\\\\uline\\)\\(\{\\)\\(\\(.\\|\n\\)+?\\)\\(\}\\)\\(\}\\)")
'(1 lawlist-regular t)
'(2 lawlist-red t)
'(3 lawlist-blue t)
'(4 lawlist-regular t)
'(5 lawlist-bold-underline t)
'(7 lawlist-regular t)
'(8 lawlist-regular t))
(list (concat "\\(\\\\begin\\|\\\\end\\)\\(\{\\)\\(document\\)\\(\}\\)")
'(1 lawlist-super-orange t)
'(2 lawlist-super-SeaGreen t)
'(3 lawlist-super-HotPink1 t)
'(4 lawlist-super-SeaGreen t))
))
(defvar lawlist-regular (make-face 'lawlist-regular))
(set-face-attribute 'lawlist-regular nil
:background "white" :foreground "black")
(defvar lawlist-bold (make-face 'lawlist-bold))
(set-face-attribute 'lawlist-bold nil
:background "white" :foreground "black" :bold t)
(defvar lawlist-bold-underline (make-face 'lawlist-bold-underline))
(set-face-attribute 'lawlist-bold-underline nil
:background "white" :foreground "black" :bold t :underline "black")
(defvar lawlist-underline (make-face 'lawlist-underline))
(set-face-attribute 'lawlist-underline nil
:background "white" :foreground "black" :underline "black")
(defvar lawlist-bumble-bee (make-face 'lawlist-bumble-bee))
(set-face-attribute 'lawlist-bumble-bee nil
:background "black" :foreground "yellow" :bold t :underline "red")
(defvar lawlist-red (make-face 'lawlist-red))
(set-face-attribute 'lawlist-red nil
:background "white" :foreground "red" :bold t)
(defvar lawlist-blue (make-face 'lawlist-blue))
(set-face-attribute 'lawlist-blue nil
:background "white" :foreground "blue" :bold t)
(defvar lawlist-green (make-face 'lawlist-green))
(set-face-attribute 'lawlist-green nil
:background "white" :foreground "green3" :bold t)
(defvar lawlist-orange (make-face 'lawlist-orange))
(set-face-attribute 'lawlist-orange nil
:background "white" :foreground "orange" :bold t)
(defvar lawlist-purple (make-face 'lawlist-purple))
(set-face-attribute 'lawlist-purple nil
:background "white" :foreground "purple" :bold t)
(defvar lawlist-pink (make-face 'lawlist-pink))
(set-face-attribute 'lawlist-pink nil
:background "white" :foreground "pink" :bold t)
(defvar lawlist-super-orange (make-face 'lawlist-super-orange))
(set-face-attribute 'lawlist-super-orange nil
:background "white" :foreground "orange" :bold t :underline nil)
(defvar lawlist-super-cyan (make-face 'lawlist-super-cyan))
(set-face-attribute 'lawlist-super-cyan nil
:background "white" :foreground "cyan" :bold t :underline nil)
(defvar lawlist-super-blue (make-face 'lawlist-super-blue))
(set-face-attribute 'lawlist-super-blue nil
:background "white" :foreground "blue" :bold t :underline nil)
(defvar lawlist-super-red (make-face 'lawlist-super-red))
(set-face-attribute 'lawlist-super-red nil
:background "white" :foreground "red" :bold t :underline nil)
(defvar lawlist-super-purple (make-face 'lawlist-super-purple))
(set-face-attribute 'lawlist-super-purple nil
:background "white" :foreground "purple" :bold t :underline nil)
(defvar lawlist-super-HotPink1 (make-face 'lawlist-super-HotPink1))
(set-face-attribute 'lawlist-super-HotPink1 nil
:background "white" :foreground "HotPink1" :bold t :underline nil)
(defvar lawlist-super-SeaGreen (make-face 'lawlist-super-SeaGreen))
(set-face-attribute 'lawlist-super-SeaGreen nil
:background "white" :foreground "SeaGreen" :bold t :underline nil)