auctex
[Top][All Lists]
Advanced

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

Re: Select and insert multiple bibliography entries into one \cite comma


From: Vladimir Lomov
Subject: Re: Select and insert multiple bibliography entries into one \cite command with regexp search.
Date: Thu, 12 Aug 2021 20:41:35 +0800

Hello,
** Hongyi Zhao <hongyi.zhao@gmail.com> [2021-08-12 17:48:21 +0800]:

> No. Your above conclusion is partially right. See my following testing 
> results:

> ---
> \documentclass{article}
> \usepackage{natbib}
> \bibliography{/home/werner/Documents/bibliograph/better-bibtex/references-bibtex.bib}
> \begin{document}

> \begin{verbatim}
>  (insert "\n" (format "%S" (symbol-value reftex-docstruct-symbol)))
> ((xr nil "\\\\\\\\\\\\") (index-tags) (is-multi nil) (bibview-cache)
> (master-dir . 
> "/home/werner/Desktop/work/emacs-auctex/reftex-docstruct-symbol/")
> (label-numbers) (bof
> "/home/werner/Desktop/work/emacs-auctex/reftex-docstruct-symbol/reftex-docstruct-symbol.tex")
> (bib "/home/werner/Documents/bibliograph/better-bibtex/references-bibtex.bib")
> (eof 
> "/home/werner/Desktop/work/emacs-auctex/reftex-docstruct-symbol/reftex-docstruct-symbol.tex"))
> \end{verbatim}

> \bibliographystyle{plainnat}
> \end{document}

> %%% Local Variables:
> %%% mode: latex
> %%% TeX-master: t
> %%% End:
> ---

You persistently provide WRONG example. The '\bibliography' command shouldn't
be used in preamble, it is meaningless! The purpose of this command is to
write necessary information into AUX file on first run and then to include BBL
file on next run (before next one must run bibtex on AUX file).

> But use the `\string~' variable to point to the bib file won't work:

> ---
> \documentclass{article}
> \usepackage{natbib}
> \bibliography{\string~/Documents/bibliograph/better-bibtex/references-bibtex.bib}
> \begin{document}

> \begin{verbatim}
>  (insert "\n" (format "%S" (symbol-value reftex-docstruct-symbol)))
> ((xr nil "\\\\\\\\\\\\") (index-tags) (is-multi nil) (bibview-cache)
> (master-dir . 
> "/home/werner/Desktop/work/emacs-auctex/reftex-docstruct-symbol/")
> (label-numbers) (bof
> "/home/werner/Desktop/work/emacs-auctex/reftex-docstruct-symbol/reftex-docstruct-symbol.tex")
> (eof 
> "/home/werner/Desktop/work/emacs-auctex/reftex-docstruct-symbol/reftex-docstruct-symbol.tex"))
> \end{verbatim}

> \bibliographystyle{plainnat}
> \end{document}

> %%% Local Variables:
> %%% mode: latex
> %%% TeX-master: t
> %%% End:
> ---

Yes, according to my tests I think RefTeX couldn't "parse" argument
'\bibliography' if it is a macro (or even starts with macro).

> The key points and some additional comments:

> 1. When you revise any part relevant to the `\bibliography' macro, the
> file must be re-parsed before do the testing discussed here.
> 2. The following options set in the init file don't ensure that the
> document is parsed automatically when we open it:
>       (setq reftex-enable-partial-scans t
>                reftex-save-parse-info t)

> 3. The `\string~' variable expansion doesn't work with RefTeX, but it
> works smoothly with helm-bibtex.

Didn't try that.

> 4. Put the `\bibliography' macro in preamble will trigger the
> xelatex/pdflatex/bibtex error as follows:

> ----
> ERROR: LaTeX Error: Missing \begin{document}.

> --- TeX said ---

> See the LaTeX manual or LaTeX Companion for explanation.
> Type  H <return>  for immediate help.
>  ...

> l.1 \begin{thebibliography}{1}

> --- HELP ---
> LaTeX produced printed output before encountering a \begin{document}
> command. Either you forgot the \begin{document} command or there is
> something wrong in the preamble. The problem may be a stray character
> or an error in a declaration---for example, omitting the braces around
> an argument or forgetting the \ in a command name.
> ----

Exactly!

> To conclude:

> 1. If you use helm-bibtex, the following example works smoothly:

> ---
> \documentclass{article}
> \usepackage{natbib}

> \begin{document}

> \begin{verbatim}
>  (insert "\n" (format "%S" (symbol-value reftex-docstruct-symbol)))
> \end{verbatim}

> \cite{weiFirstprinciplesCharacterizationBibased2009}

> \bibliographystyle{plainnat}
> \bibliography{\string~/Documents/bibliograph/better-bibtex/references-bibtex.bib}

> \end{document}

> %%% Local Variables:
> %%% mode: latex
> %%% TeX-master: t
> %%% End:
> ---

Would this example

%%% doc-samp7.ltx
------------------------------------------------------------------------------
\documentclass{article}

\usepackage{natbib}
\newcommand{\BibDB}{/home/vladimir/tmp/test/emacs/sample.bib}

\begin{document}

Sample text. Cite: \cite{test:2021aug}.

\begin{verbatim}
(insert "\n" (format "%S" (symbol-value reftex-docstruct-symbol)))
\end{verbatim}

Another cite: \cite{test2:2021aug}.

\bibliographystyle{plainnat}
% \bibliography{sample.bib}
\bibliography{\BibDB}

\end{document}

%%% Local Variables:
%%% TeX-master: t
%%% End:
------------------------------------------------------------------------------

work? Please don't forget that (La)TeX is programming language, though a bit
specific, you shouldn't expect that any program except TeX could correctly
parse (La)TeX document.

> But the following error will be triggered when using RefTeX to insert
> the references:

> reftex-offer-bib-menu: No valid bibliography in this document, and no
> default available

> 2. The following example works smoothly with both RefTeX and helm-bibtex:

> ---
> \documentclass{article}
> \usepackage{natbib}

> \begin{document}

> \begin{verbatim}
>  (insert "\n" (format "%S" (symbol-value reftex-docstruct-symbol)))
> \end{verbatim}

> \bibliographystyle{plainnat}
> \bibliography{/home/werner/Documents/bibliograph/better-bibtex/references-bibtex.bib}

> \end{document}

> %%% Local Variables:
> %%% mode: latex
> %%% TeX-master: t
> %%% End:
> ---

The advice is simple: don't use full path, try to put your bibtex files into
$HOME/texmf/bibtex/bib/hongyi/

> Best regards,
> Hongyi

---
WBR, Vladimir Lomov

-- 
"Why waste negative entropy on comments, when you could use the same
entropy to create bugs instead?"
                -- Steve Elias

Attachment: signature.asc
Description: PGP signature


reply via email to

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