I would like to have the following workflow. First, I create a global bib file, which contains all bibliography entries that I may use across all projects. Then, for each project, I can create an empty bib file for that project (or use reftex-create-bibtex-file). Whenever I call reftex-citation, that entry in the global bib file was copied to the project specific bib file.

Is this possible in Emacs?

  • The right answer to this one would be: Clearly, it is possible. (You note the sarkasm. It sounds like a specification for an engineering task.) Have a look at ebib. One of its ''LaTeX integration'' capabilities is: "Creating a .bib file from a .bbl file, allowing you to create a .bib file for a LaTeX document containing only the references in the document. (Currently only works for .bbl files generated by BibTeX.)" – Tobias Sep 20 '17 at 4:59
  • @Tobias Thanks. Actually this can also be done by using reftex-create-bib-file. The question, however, is how to set a global bib file such that reftex or ebib can extract references from that file. – xuhdev Sep 20 '17 at 17:38
  • You could first use the global bibfile for \bibliography, let latex and bibtex do their jobs. At the end you let ebib create the local bibliography file from the bbl file. – Tobias Sep 20 '17 at 17:48
  • @Tobias Thanks for pointing it out. This was the way I did before, until now I have to colaborate with other people on editing the source files, which makes this approach unfeasible anymore, as far as I can tell. Do you have any better ideas for this situation? – xuhdev Sep 20 '17 at 17:49
  • You should have added reftex-create-bibtex-file to your question. – Tobias Sep 20 '17 at 18:10

You can locally override the behavior of reftex-get-bibfile-list to return the global bibliographies.

(defcustom reftex-global-bibfile-list '()
  "List of global bibliographies for `reftex-mode'"
  :group 'reftex-citation-support
  :type '(repeat string))

(defun reftex-global-bibfile-list ()
  "Just returns `reftex-global-bibfile-list'.
Can be used as local advice of `reftex-get-bibfile-list'"

(defun reftex-create-bibtex-file-from-global (bibfile)
  "See `reftex-create-bibtex-file'.
The only modification is that not the bibfile list of the LaTeX file is used but
  (interactive "FNew BibTeX file:")
        (advice-add #'reftex-get-bibfile-list :override #'reftex-global-bibfile-list)
        (reftex-create-bibtex-file bibfile))
    (advice-remove #'reftex-get-bibfile-list #'reftex-global-bibfile-list)))
| improve this answer | |
  • Thanks! It would be nice to see this integrated in reftex. – xuhdev Sep 20 '17 at 18:17
  • @xuhdev A regular implementation would look very different. Furthermore, there are many variations of the theme. For an instance: Instead of replacing the action of reftex-get-bibfile-list one could always add an extra-list of bibliographies in reftex-get-bibfile-list from some emacs-variable. – Tobias Sep 20 '17 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.