1

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\\)" 
                                 0
                                 'font-latex-warning-face)))

(font-lock-add-keywords 'latex-mode '(("addlines" 
                                            0
                                            'font-latex-warning-face)))

I am using GNU Emacs 24.5.1.

  • Have you tried the customize interface? (M-x customize-group font-latex). – JeanPierre Mar 6 '16 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. – Stefan Müller Mar 6 '16 at 13:17
  • You are not using AUCTeX, so the solution is completely different. – Gilles Mar 7 '16 at 21:47
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)))
0

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, privacy policy and cookie policy

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