Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Adding additional highlighted keywords in Emacs+AUCTeX messes up conventional highlighting. My code:

(defvar my-new-face (make-face 'my-new-face))
(defvar my-another-new-face (make-face 'my-another-new-face))
(set-face-background 'my-new-face "Aquamarine")
(set-face-foreground 'my-new-face "Black")
(set-face-background 'my-another-new-face "Plum")
(set-face-foreground 'my-another-new-face "Black")


(font-lock-add-keywords
'latex-mode
'(("\\\\quad" 1 my-new-face prepend)
 ("\\\\label" 1 my-another-new-face prepend)))

Any suggestions how can I overcome this. Adding user keyword classes in Auctex customization menu doesn't highlight them in math-mode.

share|improve this question
add comment

1 Answer

The code provided is "almost" OK: the error is that there are no subexpressions in the regular expressions for \quad and \label, so its an error to refer to subexpression 1: one should either use subexpression 0, i.e. the full regular expression, or define a subexpression. More explicitly:

(font-lock-add-keywords
 'latex-mode
 '(("\\\\quad" 0 my-new-face prepend)
  ("\\\\label" 0 my-another-new-face prepend)))
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.