[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Select and insert multiple bibliography entries into one \cite comma
From: |
Arash Esbati |
Subject: |
Re: Select and insert multiple bibliography entries into one \cite command with regexp search. |
Date: |
Thu, 12 Aug 2021 21:59:22 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 |
Vladimir Lomov <lomov.vl@yandex.ru> writes:
> The advice is simple: don't use full path, try to put your bibtex files into
> $HOME/texmf/bibtex/bib/hongyi/
I agree.
Besides, we could teach RefTeX to ignore the \string macro in the
argument of \bibliography by patching the function
`reftex-locate-bibliography-files'. Non-compilable .tex file:
--8<---------------cut here---------------start------------->8---
\documentclass{article}
\usepackage{natbib}
\bibliographystyle{plainnat}
\begin{document}
\begin{verbatim}
(defun reftex-locate-bibliography-files (master-dir &optional files)
"Scan buffer for bibliography macros and return file list."
(unless files
(save-excursion
(goto-char (point-min))
;; when biblatex is used, multiple \bibliography or
;; \addbibresource macros are allowed. With plain bibtex, only
;; the first is used.
(let ((using-biblatex (reftex-using-biblatex-p))
(again t))
(while (and again
(re-search-forward
(concat
;; "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\("
"\\(^\\)[^%\n\r]*\\\\\\("
(mapconcat #'identity reftex-bibliography-commands "\\|")
;; "\\)\\(\\[.+?\\]\\)?{[ \t]*\\([^}]+\\)")
;; Patched regexp:
"\\)\\(\\[.+?\\]\\)?{[ \t]*\\(?:\\\\string\\|noexpand[
\t]*\\)?\\([^}]+\\)")
nil t))
(setq files
(append files
(split-string (reftex-match-string 4)
"[ \t\n\r]*,[ \t\n\r]*")))
(unless using-biblatex
(setq again nil))))))
(when files
(setq files
(mapcar
(lambda (x)
(if (or (member x reftex-bibfile-ignore-list)
(delq nil (mapcar (lambda (re) (string-match re x))
reftex-bibfile-ignore-regexps)))
;; excluded file
nil
;; find the file
(reftex-locate-file x "bib" master-dir)))
files))
(delq nil files)))
\end{verbatim}
\begin{verbatim}
(insert "\n"
(format "%S" (symbol-value reftex-docstruct-symbol)))
\end{verbatim}
% Put the name of your .bib file in the argument:
\bibliography{\string~/path/to/bib-file-sans-extension}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
--8<---------------cut here---------------end--------------->8---
Open this file, adjust the argument of \bibliography to your .bib file,
let RefTeX parse the file and eval the (insert ...) form. RefTeX will
fail to put the (bib "~/path/to/bib-file-sans-extension") into
`reftex-docstruct-symbol'. Now eval the function, parse the file and
eval the (insert ...) form again. It should work now.
I won't push this change to RefTeX/Emacs repo since I think it is a hack
and a clear solution is already there: The simple advice above and
`reftex-bibpath-environment-variables'.
Best, Arash
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., (continued)
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., Hongyi Zhao, 2021/08/12
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., Vladimir Lomov, 2021/08/12
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., Hongyi Zhao, 2021/08/12
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., Hongyi Zhao, 2021/08/12
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., Arash Esbati, 2021/08/12
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., Vladimir Lomov, 2021/08/12
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., Hongyi Zhao, 2021/08/12
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., Arash Esbati, 2021/08/14
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., Hongyi Zhao, 2021/08/12
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., Hongyi Zhao, 2021/08/12
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search.,
Arash Esbati <=
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., Hongyi Zhao, 2021/08/12
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., Hongyi Zhao, 2021/08/12
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., Arash Esbati, 2021/08/11
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., Vladimir Lomov, 2021/08/11
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., Hongyi Zhao, 2021/08/11
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., Vladimir Lomov, 2021/08/11
- Re: Select and insert multiple bibliography entries into one \cite command with regexp search., Hongyi Zhao, 2021/08/11