bug-auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24667: AUCTeX citation color


From: Mosè Giordano
Subject: bug#24667: AUCTeX citation color
Date: Wed, 12 Oct 2016 01:41:08 +0200

Hi Travis,

2016-10-11 12:49 GMT+02:00 Travis Knepp <address@hidden>:
> Coloring of citations (when using \citep, \citet, etc. as opposed to just
> using \cite) is not properly working.  Details from the stackexchange post
> (http://emacs.stackexchange.com/questions/27591/auctex-citation-color) are
> here:
>
>
>
> 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}"?

you can find the answer in the documentation ( (info
"(auctex)Fontification of macros") or
https://www.gnu.org/software/auctex/manual/auctex.html#Fontification-of-macros):

    Highlighting of macros can be customized by adapting keyword lists
    which can be found in the customization group `font-latex-keywords'.

Thus, you have to issue M-x customize-group RET font-latex-keywords
RET and then add to the "Font Latex Match Reference Keywords" variable
the new entry with "citep" (without quotes) as "keyword" field and
"*[[{" (without quotes) as "format" field.  If you want instead to
write some Elisp, you can put this

--8<---------------cut here---------------start------------->8---
(font-latex-add-keywords
 '(("citep" "*[[{"))
 'reference)
--8<---------------cut here---------------end--------------->8---

inside the hook.

Out of curiosity, do you use natbib or jurabib packages?  If you have
parsing enabled, you should automatically get fontification of citep
macro.

Bye,
Mosè





reply via email to

[Prev in Thread] Current Thread [Next in Thread]