2

I have defined a macro \mpunct{...} which I would like to be displayed in the same face as \mbox{...} is (i.e. green, not red as the rest of the text in math mode).

I don't know if it matters, anyway, \mbox is in the class "function" in font-latex.el.

Do I have to define my own keyword class, or is it better to add it to the list "function"?

Also, do I have to set it in my .emacs or is it possible to do it in a style file?

  • I should have pointed out that I use color-theme-solarized, hence the colors mentioned. – Arch Stanton Sep 28 '17 at 7:55
2

It can be done with the following code in one's .emacs file:

;; Fontify some macros
(setq font-latex-user-keyword-classes
      ;; Make <\macroname> display with the same face as \mbox.
      ;; \mbox is classified as "function" in font-latex.el and as such it uses the face font-lock-function-name-face.
      '(("my-function"  (("macroname" "{")) font-lock-function-name-face command)))

See
https://tex.stackexchange.com/questions/326706/efficiently-highlight-known-math-macros-in-auctex https://www.gnu.org/software/auctex/manual/auctex/Fontification-of-macros.html

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.