auctex
[Top][All Lists]
Advanced

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

Re: [AUCTeX] Defining new citation formats with natbib


From: Ralf Angeli
Subject: Re: [AUCTeX] Defining new citation formats with natbib
Date: Thu, 18 Jan 2007 20:40:57 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.92 (gnu/linux)

* Sven Bretfeld (2007-01-15) writes:

> I use the natbib package with multibib for a book project and I mostly
> need the commands \citealtse{} \citetse{} \citealtpr{} \citetpr{}
> (where se and pr stand for secondary resp. primary literature).
>
> I've tried to make RefTeX providing these citation formats as options
> when I hit C-c [. After experimenting in vain for a while, I put
> the following code, which I found via Google, in my .emacs file:
>
> (defun my-LaTeX-mode-setup ()
>   ;; Set up my own cite format for natbib.  (when (and (fboundp
>   'reftex-set-cite-format)
>              (member "natbib" (TeX-style-list)))
>     (reftex-set-cite-format
>      '((?\C-m . "\\cite{%l}")
>        (?s . "\\citealtse{%l}") (?S . "\\citetse{%l}") (?p
>        . "\\citealtpr{%l}") (?P . "\\citetpr{%l}") (?e
>        . "\\citep[e.g.][]{%l}") (?s . "\\citep[see][]{%l}") (?a
>        . "\\citeauthor{%l}") (?A . "\\citeauthor*{%l}") (?y
>        . "\\citeyear{%l}") (?Y . "\\citeyearpar{%l}") (?n
>        . "\\nocite{%l}")))))
>
> (add-hook 'LaTeX-mode-hook 'my-LaTeX-mode-setup)
>
> But still RefTeX presents only the default list of citation formats
> when I hit C-c [. Can anybody see the mistake?

I'm not sure if you are using the code like cited above.  If you do
this won't work because part of it is commented.  Try the following
reformatted version instead (which is working fine with my
installation):

(defun my-LaTeX-mode-setup ()
  ;; Set up my own cite format for natbib.
  (when (and (fboundp 'reftex-set-cite-format)
             (member "natbib" (TeX-style-list)))
    (reftex-set-cite-format
     '((?\C-m . "\\cite{%l}")
       (?s . "\\citealtse{%l}")
       (?S . "\\citetse{%l}")
       (?p . "\\citealtpr{%l}")
       (?P . "\\citetpr{%l}")
       (?e . "\\citep[e.g.][]{%l}")
       (?s . "\\citep[see][]{%l}")
       (?a . "\\citeauthor{%l}")
       (?A . "\\citeauthor*{%l}")
       (?y . "\\citeyear{%l}")
       (?Y . "\\citeyearpar{%l}")
       (?n . "\\nocite{%l}")))))
(add-hook 'LaTeX-mode-hook 'my-LaTeX-mode-setup)

If that doesn't work for you, please send a bug report using `M-x
TeX-submit-bug-report RET' which will provide information about your
installation necessary for finding the cause of the problem.

-- 
Ralf




reply via email to

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