1 ;;; natbib.el --- Style hook for the NatBib package
3 ;;; AUTHOR: Carsten Dominik <dominik@strw.leidenuniv.nl>
4 ;;; building on older code from Berwin Turlach
8 (TeX-add-style-hook "natbib"
11 ;; The number in the cdr of the following list indicates how many
12 ;; optional note arguments we consider useful. Prompting for those
13 ;; arguments will still depend upon `TeX-arg-cite-note-p'.
16 ("citet" . 1) ("citet*" . 1) ("citealt" . 1) ("citealt*" . 1)
17 ("citep" . 2) ("citep*" . 2) ("citealp" . 2) ("citealp*" . 2)
18 ("citeauthor" . 0) ("citeauthor*" . 0) ("citefullauthor" . 0)
19 ("citeyear" . 0) ("citeyearpar" . 0)
29 ;; No optional arguments
30 (list (car cmd) 'TeX-arg-cite))
32 ;; Just one optional argument, the post note
35 '(TeX-arg-conditional TeX-arg-cite-note-p (["Post-note"]) nil)
41 '(TeX-arg-conditional TeX-arg-cite-note-p (natbib-note-args) nil)
45 ;; Add the other symbols
48 '("bibpunct" ["Post note separator"]
51 "Punctuation between multiple citations"
52 "style [n]umeric [s]uperscript [a]uthor-year"
53 "Punctuation between author and year"
54 "Punctuation between years for common authors")
55 '("citestyle" "Style")
60 ;; Make an entry in TeX-complete-list
65 (mapconcat (lambda (x) (regexp-quote (car x)))
67 "\\)\\(\\[[^]\n\r\\%]*\\]\\)*{\\([^{}\n\r\\%,]*,\\)*\\([^{}\n\r\\%,]*\\)")
68 4 'LaTeX-bibitem-list "}")))
71 (when (and (fboundp 'font-latex-add-keywords)
72 (eq TeX-install-font-lock 'font-latex-setup))
73 (font-latex-add-keywords '(("cite" "*[[{")
79 ("citefullauthor" "[[{")
86 (if (fboundp 'reftex-set-cite-format)
87 (reftex-set-cite-format 'natbib)))))
89 (defun natbib-note-args (optional &optional prompt definition)
90 "Prompt for two note arguments a natbib citation command."
91 (if TeX-arg-cite-note-p
92 (let* ((pre (read-string
93 (TeX-argument-prompt optional optional "Pre-note")))
95 (TeX-argument-prompt optional optional "Post-note"))))
96 (if (not (string= pre "")) (insert "[" pre "]"))
97 (if (not (string= post ""))
99 ;; Make sure that we have an empty post note if pre is not empty
100 (if (string= pre "") (insert "[]"))))))
102 (defvar LaTeX-natbib-package-options '("numbers" "super" "authoryear"
103 "round" "square" "angle" "curly"
104 "comma" "colon" "nobibstyle"
105 "bibstyle" "openbib" "sectionbib"
106 "sort" "sort&compress"
107 "longnamesfirst" "nonamebreak")
108 "Package options for the natbib package.")
110 ;; natbib.el ends here