[Tex/LaTex] How to organize a .bib file edited by hand


Normally I use zotero and its bibtex/biblatex export tool to create a .bib file. But this method doesn't put you in charge of the bibliography and you could reproduces errors in the references if zotero fails to retrieve the right data (or if the conversion to bib(La)TeX is wrong).

Therefore, I am considering the possibility to go back to the old method; manage my bibliography within a single .bib edited by hand. I used to do this with the help of Emacs+AUCTeX. It is very simple to enter the different field with Emacs and to create references. However, the file is not organized; there is no order of references. Emacs writes references where the cursor is.

I would like to have some minimum order inside this .bib file. For example, the references could be order alphabetically by name of author. How can I achieve this? And, more generally, what are the tools available to manager a .bib file by hand? (to search inside for example). I have to precise I don't want to use JabRef.

Best Answer

bibtool can sort your .bib file, among many other things. Although I do edit my bibliography file by hand, I don't use it much for this task, because emacs provides a better solution (see the comment by giordano, e.g.).

To sort by bibkey, it is as simple as (options are not grouped here for clarity):

bibtool -s -i input.bib -o output.bib

To reverse sort by bibkey, use:

bibtool -S -i input.bib -o output.bib

(Note that this tool therefore encourages a rational bibkey naming strategy. Ideally, your bibkeys are logically connected to the author or editor field. E.g., an article written by John Smith and published in the year 2000 would have something like smith2000 as the bibkey. If further disambiguation is needed, I recommend adding the first letters of the first four words: so smith2000aaos might be used for Smith's article with a title like 'An Article on Stuff. My .bib file has about 2700 entries [and growing] and there are no duplicate bibkeys with this system.)

[Edit:] Recent versions of bibtool allow sorting by specific fields. For instance, to sort by author, use

bibtool -s –sort.format=”%N(author)” input.bib output.bib

See the manual for more details.

Related Question