When inserting a reference in a LaTeX document (using Auctex) I normally type:
\cite{joebob_2010}
where "\cite" shows up in blue font, while "joebob_2010" shows up reddish/purple. I like this coloring. However, when I use
\citep{joebob_2010}
all text shows up white.
In my .emacs file I put:
(add-hook 'LaTeX-mode-hook
(lambda ()
(font-lock-add-keywords nil '(("\\(\\\\citep\\)\\s-*{" 1 font-lock-keyword-face t)))
(font-lock-add-keywords nil '(("\\(\\\\citet\\)\\s-*{" 1 font-lock-keyword-face t)))
))
This changed the color of "\citep" to blue, but the reference to "joebob_2010" remains white. Can I modify this to have the same coloring as "\cite{joebob_2010}"?
EDIT/SOLUTION
I posted a bug report to the gnu group for Auctex and found out there was no bug after all. The following solution works. In the .emacs file, put:
;; set special font highlighting for \cite* commands
(add-hook 'LaTeX-mode-hook
(lambda ()
(font-lock-add-keywords nil '(("\\(\\\\citep\\)\\s-*{" 1 font-lock-keyword-face t)))
(font-lock-add-keywords nil '(("\\(\\\\citet\\)\\s-*{" 1 font-lock-keyword-face t)))
(font-latex-add-keywords '(("citep" "*[[{")) 'reference)
(font-latex-add-keywords '(("citet" "*[[{")) 'reference)
))
Adding the keywords at the end is the key.
(setq TeX-parse-self t)
in your init file and restart Emacs. Auctex should then load the relevant style (natbib.el
orbiblatex.el
) and fontify the macros respectively.biblatex.el
is in a path mentioned inTeX-style-path
variable. The easiest way is to use elpa to update AUCTeX.C-c C-n
. You are missing a lot of features provided by that style; you should get it running.