[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Supporting multibib in RefTeX
From: |
Arash Esbati |
Subject: |
Supporting multibib in RefTeX |
Date: |
Wed, 27 Apr 2022 13:35:50 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 |
Hi all,
based on this question[1], I had a closer look how to support multibib
package in RefTeX. The issue is that multibib creates new macros to
read bibliography databases with \newcites. Example:
\documentclass{article}
\usepackage{multibib}
\newcites{ltex}{\TeX\ and \LaTeX\ References}
\begin{document}
References to the \TeX book \citeltex{Knuth:1991}
and to Lamport’s \LaTeX\ book, which appears
only in the references\nociteltex{Lamport:1994}.
Finally a cite to a Postscript tutorial
\cite{Adobe:1985}.
\bibliographystyleltex{alpha}
\bibliographyltex{lit}
\renewcommand{\refname}{Postscript References}
\bibliographystyle{plain}
\bibliography{lit}
\end{document}
RefTeX searchs only for one bibliography command when
`reftex-locate-bibliography-files' is invoked which is the standard with
vanilla LaTeX.
The following patch tells RefTeX that multibib also supports more than
one bibliography command. Before I install it, are there other packages
I'm missing?
--8<---------------cut here---------------start------------->8---
-> git diff lisp/textmodes/reftex-parse.el
diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el
index 016c9cf399..bae455dd4d 100644
--- a/lisp/textmodes/reftex-parse.el
+++ b/lisp/textmodes/reftex-parse.el
@@ -370,13 +370,18 @@ reftex-parse-from-file
docstruct))
(defun reftex-using-biblatex-p ()
- "Return non-nil if we are using biblatex rather than bibtex."
+ "Return non-nil if we are using biblatex or other specific cite package.
+biblatex and other packages like multibib allow multiple macro
+calls to load a bibliography file. This packages should be
+detected by this function."
(if (boundp 'TeX-active-styles)
;; the sophisticated AUCTeX way
- (member "biblatex" TeX-active-styles)
+ (or (member "biblatex" TeX-active-styles)
+ (member "multibib" TeX-active-styles))
;; poor-man's check...
(save-excursion
- (re-search-forward "^[^%\n]*?\\\\usepackage.*{biblatex}" nil t))))
+ (re-search-forward
+ "^[^%\n]*?\\\\usepackage\\(\\[[^]]*\\]\\)?{biblatex\\|multibib}" nil
t))))
;;;###autoload
(defun reftex-locate-bibliography-files (master-dir &optional files)
@@ -384,7 +389,7 @@ reftex-locate-bibliography-files
(unless files
(save-excursion
(goto-char (point-min))
- ;; when biblatex is used, multiple \bibliography or
+ ;; when biblatex or multibib are used, multiple \bibliography or
;; \addbibresource macros are allowed. With plain bibtex, only
;; the first is used.
(let ((using-biblatex (reftex-using-biblatex-p))
@@ -392,7 +397,7 @@ reftex-locate-bibliography-files
(while (and again
(re-search-forward
(concat
- ;; "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\("
+ ;; "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\("
"\\(^\\)[^%\n\r]*\\\\\\("
(mapconcat #'identity reftex-bibliography-commands "\\|")
"\\)\\(\\[.+?\\]\\)?{[ \t]*\\([^}]+\\)")
@@ -415,7 +420,7 @@ reftex-locate-bibliography-files
;; find the file
(reftex-locate-file x "bib" master-dir)))
files))
- (delq nil files)))
+ (delq nil (delete-dups files))))
(defun reftex-replace-label-list-segment (old insert &optional entirely)
"Replace the segment in OLD which corresponds to INSERT.
--8<---------------cut here---------------end--------------->8---
As always, any comments welcome.
Best, Arash
Footnotes:
[1] https://lists.gnu.org/archive/html/auctex/2022-01/msg00014.html
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Supporting multibib in RefTeX,
Arash Esbati <=