58

I have a BibTeX database with some big number of references which I use for work. When I need to send a document prepared using that database to somone I have two options: either send a full copy of the database (which I would not like to do), or copy all referenced entries from a large database to a smaller copy, and send that copy with a document. Are there any tools which would do this automatically?

5
  • 4
    Is the recipient going to edit the bibliography? If not you can just send the .bbl file generated by BibTeX, which should contain only those citation entries actually used in the document. Open up the .bbl file in a text editor and you'll see what I mean. Commented Jul 27, 2010 at 20:48
  • 1
    Yes, I would like to send an editable bibliography.
    – abbot
    Commented Jul 27, 2010 at 21:03
  • Since the \citation{} and \bibcite{} commands are in the .aux files, it should be quite easy to extract the relevant entries from a BibTeX database. Has no-one written such a tool? Commented Jul 27, 2010 at 21:39
  • 1
    @stefan-pinnow, and other 'vote to close' voters, I'm very curious to know, how come that the question asked in 2010 can be a duplicate of a question asked in 2012. This is not how time works, really.
    – abbot
    Commented Nov 12, 2019 at 11:58
  • @abbot Strictly speaking you are right - the other post is a duplicate of this one and it should have been closed. Unfortunately that was not noticed in time and now the other post has many good answers, so I think this post was correctly closed as a duplicate. As the statement above says, This question already has an answer here: tex.stackexchange.com/questions/41821/…
    – user30471
    Commented Nov 12, 2019 at 13:08

9 Answers 9

35

BibTool is a command-line tool which allows you to perform various manipulations on .bib files, including extracting all of the entries which are mentioned in a given .aux file.

2
  • 22
    I think you should mention how to usebibtool that is: bibtool -x file.aux -o refs.bib for example. For biblatex users, this question is relevant
    – Seamus
    Commented Mar 31, 2011 at 20:37
  • Also note that by default bibtool searches for the bib files in the same way as bibtex does. For instance, to have it pick up bib files only in the current directory one can use BIBINPUTS=:.: bibtool -x file.aux -o refs.bib.
    – orbeckst
    Commented Apr 28, 2014 at 20:37
18

A reference manager such as JabRef will allow you to save selected entries from your entire .bib database to a new, smaller .bib file. JabRef also allows you to export to many other formats, such as XML, HTML, EndNote, and Harvard RTF.

2
  • 9
    Jabref can extract the entries based on .aux file and write them to a new .bib file.
    – Pedro J. Aphalo
    Commented Jul 28, 2010 at 10:22
  • 3
    Jabref > Tools > New subdatabase based on AUX file.
    – dips
    Commented Jul 5, 2014 at 11:35
12

You could also try M-x reftex-create-bibtex-file if you're using Emacs and RefTeX.

4
  • my reftex doesn't seem to have this feature. The only autocomplete options for reftex-create- are reftex-create-customize-menu and reftex-create-tags-file
    – Seamus
    Commented Mar 16, 2011 at 13:17
  • 1
    @Seamus: seems to be a bug in reftex's autoloads; try loading the reftex-site library first?
    – SamB
    Commented Mar 17, 2011 at 23:01
  • That works! Thanks. Except this method seems to fail to find references with optional arguments: \cite{foo} gets put in the bib, but \cite[p.1]{foo} doesn't...
    – Seamus
    Commented Mar 21, 2011 at 16:34
  • 1
    @Seamus I also had this problem: was was able to use the menu item, but the tool seems quite broken (multiple citations also seem to fail.)
    – mforbes
    Commented Feb 23, 2013 at 0:45
7

I use a shell script called bibexport

bibexport: a tool to extract BibTeX entries out of .bib files.
usage: .../bibexport [-h|v] [-n] [-b bst] [-a [-e file]...] [-o file] file...
  -a, --all          export the entire .bib files
  -b, --bst          specifies the .bst style file  [default: export.bst]
  -e, --extra        extra .bib files to be used (for crossrefs)
  -c, --crossref     include entries that are crossref'd   [default: yes]
  -n, --no-crossref  don't include crossref'd entries       [default: no]
  -o file            write output to file        [default: bibexport.bib]
  -h, --help         print this message and exit
  -v, --version      print version number and exit
1
  • is it possible to use this in overleaf to extract cited bib entries from a larger bibfile? Commented Nov 7, 2022 at 9:09
5

The current download of JabRef will not run for me on OS 10.10.2 (OS X says it is 'damaged'.) But BibDesk also provides a way of doing this.

  1. Open your large .bib in BibDesk.
  2. Create a new, empty Bibliography.
  3. Click Database > 'Select Publications from .aux File'
  4. Navigate to the .aux file for your document.
  5. All entries cited in your document will now be selected. Drag them into the empty Bibliography. Save and rejoice.

I have had many journals request a separate .bib of this kind rather than a .bbl.

1
  • Nice. Just a clarification: you need to do Step 2 on your open large .bib file, not in the new empty bibliography.
    – epsilone
    Commented Dec 4, 2022 at 12:25
3

latex2html has a tool called aux2bib which does the job.

2
  • +1 because in contrast to other tools, latex2html is included in / installable by the TeX distributions TeX Live and MiKTeX.
    – matth
    Commented Feb 25, 2012 at 13:48
  • @JosephWright Could it be that aux2bib is a part of 'btex2html` and not really of latex2html?
    – Paulo Ney
    Commented Jun 14, 2019 at 10:52
2

With biblatex use

biber --output-format=bibtex file.bcf
1

Or again Mendeley -- with it you could even have a shared collection which will stay in sync.

1
  • 1
    could you elaborate how to do this, please? I use Mendeley synced with overleaf but my Mendeley bib is too big, so I want to only have cited bib-entries in it. Commented Nov 7, 2022 at 9:10
-1

In Bookends, you create a folder for your specific references. After dragging the references to it you can easily export the folder to a bib file. I use an Apple Script to speed things up.

Not the answer you're looking for? Browse other questions tagged .