2

I have a large refs.bib file where I collect all my bibliography. I'd like to export only the relevant bibtex entries cited in a org document. So then I can email the document.bib and document.tex files to my collaborators.

I am pretty sure this piece of functionality already exists but I haven't been able to find it.

1
3

If you are using org-ref see org-ref-extract-bibtex-entries or org-ref-extract-bibtex-to-file.

2
  • Am I supposed to call =org-ref-extract-bibtex-to-file= from document.org? If I do so the whole document get pasted to the chosen .bib file.
    – Federico
    Mar 16 at 10:24
  • you should call M-x org-ref-extract-bibtex-to-file in the org file to extract the entries from. it should create a bib file that is derived from the org file name that contains the bibtex entries you cited in the org file. Mar 16 at 10:51
1

I have a large refs.bib file where I collect all my bibliography. I'd like to export only the relevant bibtex entries cited in a org document.

The bog package provides a command bog-create-combined-bib that can do something like this:

bog-create-combined-bib is an autoloaded interactive compiled Lisp function in
`bog.el'.

(bog-create-combined-bib &optional ARG)

Create a buffer that has entries for a collection of citekeys.
If in Dired, collect citekeys from marked files.  Otherwise,
collect citekeys from the current buffer.  With prefix argument
ARG, reverse the meaning of `bog-combined-bib-ignore-not-found'.

For example, with the following contents in the current org-mode buffer:

* Robin Milner
...
** milner1999communicating
Communicating and Mobile Systems: The π-Calculus
...
* tzevelekos2011fresh
...
* martens2021linear
Linear time parallel algorithm to calculate strong bisim on parallel random
access machines.
...

M-x bog-create-combined-bib RET generates the following *Bog combined bib* buffer:

@InProceedings{martens2021linear,
  author       = {Martens, Jans and Groote, Jan Friso and van den Haak, Lars and
                  Hijma, Pieter and Wijs, Anton},
  title        = {A linear parallel algorithm to compute bisimulation and
                  relational coarsest partitions},
  date         = 2021,
  booktitle    = {Proceedings of the 2021 International Conference on
                  Foundations of Software Science and Computation Structures}
}

@book{milner1999communicating,
  author       = {Milner, Robin},
  title        = {Communicating and Mobile Systems: The {$\pi$}-Calculus},
  year         = 1999,
  publisher    = {Cambridge University Press},
  isbn         = {978-0-521-65869-0}
}

@article{tzevelekos2011fresh,
  author       = {Tzevelekos, Nikos},
  title        = {Fresh-Register Automata},
  year         = 2011,
  issue_date   = {January 2011},
  publisher    = {Association for Computing Machinery},
  address      = {New York, NY, USA},
  volume       = 46,
  number       = 1,
  issn         = {0362-1340},
  url          = {https://doi-org.elib.tcd.ie/10.1145/1925844.1926420},
  doi          = {10.1145/1925844.1926420},
  abstract     = {What is a basic automata-theoretic model of computation with
                  names and fresh-name generation? We introduce Fresh-Register
                  Automata (FRA), a new class of automata which operate on an
                  infinite alphabet of names and use a finite number of
                  registers to store fresh names, and to compare incoming names
                  with previously stored ones. These finite machines extend
                  Kaminski and Francez's Finite-Memory Automata by being able to
                  recognise globally fresh inputs, that is, names fresh in the
                  whole current run. We examine the expressivity of FRA's both
                  from the aspect of accepted languages and of bisimulation
                  equivalence. We establish primary properties and connections
                  between automata of this kind, and answer key decidability
                  questions. As a demonstrating example, we express the theory
                  of the pi-calculus in FRA's and characterise bisimulation
                  equivalence by an appropriate, and decidable in the finitary
                  case, notion in these automata.},
  journaltitle = {SIGPLAN Not.},
  month        = jan,
  pages        = {295–306},
  numpages     = 12,
  keywords     = {computation with fresh-name generation, finite-memory
                  automata, register automata}
}

In my case I have a separate bib file for each entry, but bog also supports multiple entries in a single bib; you just need to customise the user options bog-find-citekey-bib-func and bog-bib-file. See the project's README for more.

1

I just went crazy looking for an answer as well. I've done it numerous times in the past, but never remembered how to do it. The key was to google without mentioning emacs!

I copy an answer from here (that I normally use): https://tex.stackexchange.com/questions/41821/creating-bib-file-containing-only-the-cited-references-of-a-bigger-bib-file

With a TeX Live distribution (possibly also with MiKTeX) there is a bibexport program. Assuming your document is myarticle.tex, you have to compile it normally and then you call

bibexport -o extracted.bib myarticle.aux

where extracted.bib is the name that you want to give to your new .bib file. Notice that you have to give the extension .aux (or no extension at all).

Then you have to change the name of the .bib file in your document, in order to use extracted.bib.

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.