55

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. Jul 27 '10 at 20:48
  • 1
    Yes, I would like to send an editable bibliography.
    – abbot
    Jul 27 '10 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? Jul 27 '10 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
    Nov 12 '19 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
    Nov 12 '19 at 13:08
34

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
  • 20
    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
    Mar 31 '11 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
    Apr 28 '14 at 20:37
17

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
    Jul 28 '10 at 10:22
  • 3
    Jabref > Tools > New subdatabase based on AUX file.
    – dips
    Jul 5 '14 at 11:35
11

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
    Mar 16 '11 at 13:17
  • 1
    @Seamus: seems to be a bug in reftex's autoloads; try loading the reftex-site library first?
    – SamB
    Mar 17 '11 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
    Mar 21 '11 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
    Feb 23 '13 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
4

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.

0
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
    Feb 25 '12 at 13:48
  • @JosephWright Could it be that aux2bib is a part of 'btex2html` and not really of latex2html?
    – Paulo Ney
    Jun 14 '19 at 10:52
2

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

2

With biblatex use

biber --output-format=bibtex file.bcf
-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 or ask your own question.