On Thu, Aug 12, 2021 at 5:48 PM Hongyi Zhao <hongyi.z...@gmail.com> wrote: [...] > 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: > --- > > 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
Sorry for my error description on the bibliography search mechanism of helm-bibtex. According to the comment here [1]: ---------------- Search in the local bibliography Use helm-bibtex-with-local-bibliography or ivy-bibtex-with-local-bibliography to start a search in the current buffer’s “local bibliography”, instead of the “global bibliography” defined by bibtex-completion-bibliography. If the current file is a BibTeX file, that bibliography is going to be used. If the current file is a LaTeX file, reftex will be used to determine the local bibliography from the standard LaTeX bibliography commands \bibliography and \addbibresource. If the file is an org file, the local and/or global org bibliography is used (as specified using the new #+BIBLIOGRAPHY: key word and the variable org-cite-global-bibliography). If no local bibliography can be found, the global bibliography (bibtex-completion-bibliography) will be used. ---------------- So helm-bibtex can use the “local bibliography” or the “global bibliography” defined by bibtex-completion-bibliography. The former is implemanted based on RefTeX, the latter relies on the customized variable bibtex-completion-bibliography. In my testings, I already difined the variable bibtex-completion-bibliography, so if no local bibliography can be found, the global bibliography (bibtex-completion-bibliography) will be used. To summarize: if RefTeX can't find the bibliography file, helm-bibtex won't find it too; but as a fallback mechanism, it can query the global bibliography (bibtex-completion-bibliography) if avaiable, which is just the situation in my testings. [1] https://github.com/tmalsburg/helm-bibtex#search-in-the-local-bibliography Best, Hongyi