As researchers, we sometimes write manuscripts collectively and remotely in
LaTeX (or in a lightweight markup languages
that is converted into LaTeX at some point). In such case, it is quite
useful to let co-authors edit their own
bib file in order to store the references included in the part of the manuscript they are editing. One way to deal with several
bib files is to merge them into one
bib file before compiling the final document to
Let’s assume that there are two
bib files within the manuscript folder:
kevcaz.bib file, my own list of references;
author.bib, my colleague’s references list.
I added these two files below:
Then, what I want is to merge them into one single file
one to be used as reference data base for the manuscript) and I also want to
remove all duplicates before the merge. How to do so? Well, that is the king of
situation where bibtool comes in handy.
This command line tool allows several manipulations of
.bib files and here I
use it to merge two
bib file, sort the entries in alphabetical order and
remove all duplicates with single line of command:
-ssorts entries in alphabetical order;
-dcomments out duplicates
-oindicate the name of the output files.
Below is the final file with two comments of my own:
Pretty neat, isn’t it? Plus, if you are familiar with
it is easy to add this to your compilation process so that each time your
file is edited, the manuscript database will be edited will be updated 😃!
I find this way quite convenient as it allows co-author to edit the list of
reference without worrying about potential conflicts in this list.
Three final remarks to conclude this post:
have a look at
man bibtool, there are several options to explore, for instance
-Sto sort entries in reverse order;
the approach described above will work seamlessly if all the authors edit the keys of the entries in the same way (as above), otherwise another step is required to standardize these keys;