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.

  • 3
    Does BibTeX-Edit > Operating on buffer or region > Sort entries help? This sorts BibTeX entries by citation key. – giordano Dec 15 '13 at 23:38
  • 1
    Well, if you use a dedicated TeX editor such as TeXMaker you can edit directly your .bib files. It let you to paste directly the bib files from Google Scholar and other sites where you can download the references in bibtex format. My favourite tool for manage and edit my references is still JabRef. Is multiplatform and can manage references in bibtex and biblatex formats, perhaps it helps you. No matter if you edit your .bib file with zotero(in fact you can import them from zotero) or by hand. – Aradnix Dec 15 '13 at 23:49

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.)

  • So what if I want it sorted by say, journal or date of publication? Is that possible? – Canageek Dec 18 '13 at 20:49
  • @Canageek -- Not to my knowledge. Even bibsort lacks that ability. I've never had the need, but GUI applications can probably do stuff like that. – jon Dec 18 '13 at 22:29
  • I print out literature lists with \nocite{*}, so it would be nice to be able to organize them, and I do the bib files by hand. Too bad. – Canageek Dec 18 '13 at 22:48
  • @Canageek -- Why not organize them with an appropriate bibliography style? It is easy to sort entries any way you want, e.g., with biblatex and biber. – jon Dec 18 '13 at 22:51
  • 1
    @Canageek -- Don't give up on it. For example, it could be as easy as using something like \DeclareSourcemap{\maps[datatype=bibtex,overwrite]{\map{\step[fieldsource=journal,fieldset=presort,origfieldval]}}} and \printbibliography[type=article] to print all articles alphabetically by journal name. – jon Dec 19 '13 at 5:06

I manage all my bib file by hand using notepad++ and copy and paste, which brings me to the long way to do it: Each entry is just text, so provided your files aren't too long, you could just copy and paste them by hand.

For longer files, things are tricker. I've not heard of a program that is made to sort bib files. However, LaTeX doesn't care about spacing so you could just put each entry on one line, and then use something like the unix sort command to put them in order and save the new file.


Emacs includes bibtex-mode, which provides functions for adding, editing and maintaining .bib files. It will maintain your entries in alphabetical order. It can also be configured to auto-generate keys for new entries based on author, year, title etc. In my case, it produces a key in the form author_author_year, so the keys look very similar to the how the entry will look after processing with natbib.

You can find the documentation from within Emacs with C-h m bibtex-mode.


Possibly one of the better programs for managing BibTeX databases is ebib, which runs inside Emacs.

Ebib allows different ways of sorting. From the manual:

You can specify a sort order in Ebib's customisation buffer. To sort the entries, you must set at least one sort level (that is, a field to sort the entries on). You can also specify more than one sort level: if two entries have identical values for the first sort level, they will be sorted on the second sort level. E.g., if the first sort level is author and the second is year, then the entries are sorted by author, and those entries that have identical values for the author field are sorted by year.

A sort level is not restricted to a single field. You can specify more fields for a single sort level. Within a single sort level, a second sort field is used if the first sort field does not have a value. For example, books that have an editor instead of an author will have an empty author field. If you sort the database on the author field, such entries will all appear at the beginning of the .bib file, which is most likely not what you want.

See Chapter Sorting the .bib File.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.