If you use emacs and LaTeX and syntax highlighting used to work
but doesn't and you want it back, all you need to do is fix your
~/.emacs
file. It probably specifies the old-fashioned
way, now broken and unsupported.
If you have something like
(if window-system (require 'hilit-LaTeX)) (setq hilit-AmSLaTeX-commands t)
either delete it or comment it out (the comment character in emacs lisp is semi-colon) and replace it with
(if window-system (require 'font-latex)) (setq font-lock-maximum-decoration t)
Syntax highlighting will now work.
But when you start up emacs on a LaTeX file there is no highlighting.
Each time you start emacs, you must select the first item on the
Options
menu, which is Syntax Highlighting (Global Font Lock mode)
. Then you see the highlighting.
As the documentation for font-latex.el --- LaTeX fontification for Font Lock mode says
Okay, so you hate the colours I picked. How do you change them you ask?
Here's what follows in my words with a little more detail.
M-x list-text-properties-at
. This is emacs-speak.
If you don't know what M-x
means, it is meta-x, meta being the emacs name (inherited from lisp machines) for the key usually labeled
Alton standard keyboards. So hold down
Alt
and press x
. Emacs
will put M-x
in the minibuffer (at the bottom of the
Emacs window) and you type list-text-properties-at
(and hit Enter).
Alt-x
works for M-x
on our Linux machines.
On some computers it doesn't and you must do Esc-x
(escape key, release escape key, then press x), which also works on
our Linux machines.
So what you do is put the cursor over some highlighted text you
want to change the color of and do
M-x list-text-properties-at
. Emacs will then show
you something like
Text properties at 785: face (font-latex-math-face font-latex-sedate-face) fontified twhich tells you that this highlighting is
font-latex-math-face
(what it was to LaTeX was math mode $\epsilon$
).
/usr/X11R6/lib/X11/rgb.txton our Linux boxes. On other Unix computers the file will still be called
rgb.txt
but may be located somewhere else. The
Unix command
locate rgb.txtshould find it. Suppose you pick the color
MediumSpringGreen
.
Emacs.font-latex-math-face.attributeForeground: MediumSpringGreenin the file
~/.Xdefaults
(create the file if you don't have one).
It should be clear how to modify this example to change the color
from, say, MediumSpringGreen
to PaleVioletRed
or to change the text property
from, say,
font-latex-math-face
to font-lock-keyword-face
(what I get when I check out the highlighting of
a LaTeX \section
command).
.Xdefaults
take effect without
logging out and back in do
xrdb -merge ~/.Xdefaults
By the way, in order to be a Unix knowledgeable user
you have
to know about .Xdefaults
and xrdb
. This is
the standard way to modify the defaults of graphical programs
(anything that makes a window). The newer KDE and Gnome stuff use
different, mouse and menus, ways to modify their defaults. But
.Xdefaults
and xrdb
it the only thing that
works on all graphical programs and the only way to modify the defaults
of older programs like xdvi
.
Author: Charles Geyer. Comments or corrections gratefully accepted.