When I try to put

 (set-face-attribute 'font-latex-italic-face nil :foreground green)
 (set-face-attribute 'font-latex-math-face nil :foreground orange)
 (set-face-attribute 'font-latex-script-char-face nil :foreground red)
 (set-face-attribute 'font-latex-string-face nil :foreground red)

into my init.el (green & are variables I have given values), I am told that 'font-latex-... are 'invalid faces'. this also happens if i try to evaluate the expressions before having opened a latex buffer. how am i suppsed to customize these faces in my init.el? (i don't want to use custom-set-faces.)

3 Answers 3


The standard method to do this sort of thing, given that the faces are defined in the font-latex library:

(with-eval-after-load 'font-latex
  (set-face-attribute 'font-latex-italic-face nil :foreground green)
  (set-face-attribute 'font-latex-math-face nil :foreground orange)
  (set-face-attribute 'font-latex-script-char-face nil :foreground red)
  (set-face-attribute 'font-latex-string-face nil :foreground red))

This way, you don't force the loading of font-latex before you need it. If the file has already been loaded, the commands will be run immediately; otherwise, they will be run after the file is loaded, as the name indicates. (Strictly speaking, they will be run after the loading of any file that runs (provide 'font-latex). But no other file should do that.)

  • Do you mean with-eval-after-load? Your example will not work as eval-after-load expects FORM as argument and needs a quoted '(progn ...) for multiple forms. Commented Feb 3, 2019 at 19:20
  • @ArashEsbati Indeed, I was a bit quick there. Thanks; edited. Looking at my own init file, I see that I made my own equivalent of the with-eval-after-load macro once, probably before that macro made it into the emacs source. I use both my home brewed macro and the official one – time to go clean that up. Commented Feb 3, 2019 at 19:55

You have to load or autoload a symbol before you can customize it. The easiest way is to insert

(require 'font-latex)

before the set-face-attribute commands.


I faced a similar issue with ediff. The faces are defined here, required here, but they're loaded only when I start resolving a conflict. But there's a ediff-load-hook in ediff.el, so I did this:

(add-hook 'ediff-load-hook
          (lambda ()
            (set-face-attribute 'ediff-even-diff-A nil :background "dim grey")
            (set-face-attribute 'ediff-odd-diff-A nil :background "dim grey")
            (set-face-attribute 'ediff-even-diff-B nil :background "dim grey")
            (set-face-attribute 'ediff-odd-diff-B nil :background "dim grey")
            (set-face-attribute 'ediff-even-diff-C nil :background "dim grey")
            (set-face-attribute 'ediff-odd-diff-C nil :background "dim grey")))

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.