Q:

How do I set latex face attributes in init.el?

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.)

A:

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.)

