Is it possible to define in the latex document also the auctex font for user macros and environments? Here is an example of what I would like to do:

%% ;;; \nothing color red style italic

and now in the remainder of the document, a \nothing{hello} would have the hello be displayed in red italics in emacs. [partial answer accepted below lacks color but has style. thx.]

1 Answer 1


Partial solution: With font-latex enabled, you can fontify your macros with a file variable:

%%% eval: (font-latex-add-keywords '(("nothing" "{" )) 'italic-command)

You have to add this line manually at the end of your LaTeX document to the local variables, e.g.:



%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% eval: (font-latex-add-keywords '(("nothing" "{" )) 'italic-command)
%%% End: 

enter image description here

AUCTeX loads and activates font-latex by default, no further tweaking needed. You can check this with C-h v TeX-install-font-lock RET:

TeX-install-font-lock is a variable defined in `tex.el'.
Its value is font-latex-setup

Documentation: Function to call to install font lock support. Choose `ignore' if you don't want AUCTeX to install support for font locking.

  • could you please add how to enable font-latex? apropos font-latex is not that helpful.
    – ivo Welch
    Aug 7, 2015 at 13:39
  • @ivoWelch - I've edited my answer. Which AUCTeX version do you have (C-h v AUCTeX-version)? And how did you install it? Aug 8, 2015 at 15:13
  • Just a quick follow-up question: Can one configure AUCTeX to automatically add some of these %%% eval: <...> lines along with the other variables it puts at the end of documents? Aug 8, 2015 at 15:58
  • 1
    @PhilippImhof - Check the definition of TeX-add-local-master in tex.el. You have to copy that function into your .emacs and tweak it then (untested). Aug 8, 2015 at 16:27
  • 2
    @PhilippImhof - I would like to discourage you from doing that. If you have macros which you use on a regular basis, put them into a package mystuff.sty and write some proper AUCTeX support mystuff.el for it. Put mystuff.el in a directory (C-h v TeX-style-private RET is a good start) and AUCTeX loads that style each time you load your package. Aug 8, 2015 at 17:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .