5

I am using AucTeX to write LaTeX and I have fontification enabled. The highlighting of marcos works but while macros like \begin are highlighted using font-lock-keyword-face all math macros (\sum, \leq to mention a few) are highlighed using font-lock-sedate-face that is reserved for ``unknown'' macros.

On the other hand AucTeX clearly has some knowledge of all these marcos since Tex-insert-macro lists many of them among possible completions. Math macros are also defined in LaTeX-math-default in latex.el.

It seems that font-latex.el does not use this information. Is there a ``best practice'' to make font-latex learn all these keywords and fontify them appropriately?

  • Math should be fontified with font-latex-math-face, inline and display. Are you sure you haven't some customization somewhere which tweaks this? – Arash Esbati Aug 27 '16 at 12:18
  • I was referring to fontifying macros in math mode, not the general math. E.g. consider $a \leq b$. a,b should be fontified using font-latex-math-face. What about \leq? it is a macro and should be detected and fontified as such. – Gennady Uraltsev Aug 28 '16 at 17:25
4

AUCTeX has built-in facilities for custom fontification. Check the documentation, section User-defined keyword classes. You have to set the variable font-latex-user-keyword-classes. I did this in my .emacs:

(setq font-latex-user-keyword-classes
      '(("mathcmds"  (("frac" "{{"))  bold-italic              command)
        ("mathnoarg" ("leq")          font-lock-warning-face   noarg)))

to get this:

enter image description here

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.