There are lots of tools and software that make bibliography management easy in LaTeX. We can keep every bibliographic entry stored in one file -- a centralized bibliographic source -- that can be linked to as many documents as desired, or we can make use of several BibTeX files and access them as needed. Problems arise when the need to collaborate or publish arises. We certainly can't send our entire .bib file now, can we? We can manually edit and create a smaller .bib file to a collaborator or an editor but this can be both difficult and tedious. If only there was a simpler way. An automated way.
It turns out there is in the form of the bibexport tool -- a Bourne shell script tool that extracts bibliography entries that are cited in a document -- and its use is pretty simple. The tool also allows you to export the cited entries from more than one .bib file.
Extracting with and without cross-references
Extracting \cite'd references of a document with cross-references is simple:
1 2 3 |
bibexport.sh -o export.bib my_file.aux |
It must be noted that you must first compile your document for the .aux file to be available. But what if we needed to extract references without cross references and using a BibTeX style (.bst) file. Well, that too is simple.
1 2 3 |
bibexport.sh -b your_style.bst -o export.bib my_file.aux |
Extracting from more than one BibTeX file
Sometimes we have more than one bibliographic database or .bib file. Again, this helpful tool takes care of that problem.
1 2 3 |
bibexport.sh -a -n -o export.bib my_file1.bib my_file2.bib |
Using it all
Now that all the hard work has been done -- no sarcasm here -- we can now include the new extracted .bib file in our document. And who said LaTeX has to be difficult?