I want the commands \largerpage and \addlines to be displayed in red (font-latex-match-warning-keywords) but cannot figure out how to do this. I found several posts, but non of this seems to work.

This is what I tried:

;; \font-latex-warning-face
(setq font-latex-match-warning-keywords
        ("addlines" "") 

 (font-lock-add-keywords nil '(("\\(addlines\\) \\(largerpage\\)" 

(font-lock-add-keywords 'latex-mode '(("addlines" 

I am using GNU Emacs 24.5.1.

  • Have you tried the customize interface? (M-x customize-group font-latex).
    – JeanPierre
    Commented Mar 6, 2016 at 9:10
  • I do not have a font-latex. Maybe I do not have auctex loaded. May .emace does not say anything about loading it. But I get syntax highliting for latex. Commented Mar 6, 2016 at 13:17
  • You are not using AUCTeX, so the solution is completely different. Commented Mar 7, 2016 at 21:47

2 Answers 2


I found the solution: https://www.emacswiki.org/emacs/AddKeywords

(font-lock-add-keywords 'latex-mode
                        '(("addlines" . font-lock-warning-face)
                          ("largerpage" . font-lock-warning-face)))
  • Shouldn't that be "\\\\addlines" and "\\\\largerpage" to add the leading (single) slash (doubly escaped)? I wanted to add \cli{} as a keywaord (command) and without slashes, any cli substring is coloured.
    – AstroFloyd
    Commented Jul 27, 2021 at 18:47

The documentation suggests to use the customization group font-lock-keywords. First visit a latex file to ensure AUCTeX is loaded, then do M-x customize-group font-latex-keywords, navigate to Font Latex Match Warning Keywords, INSert your keywords, apply Save for future sessions and restart emacs.

If the customization group is unknown, do M-: (require 'font-latex) first. (It's not clear to me when/why it's necessary.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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