20

I have some .bib files whose formatting is kind of messy: spacing, upper/lowercase use, order within and among entries... ugh. Is there a simple command-line utility which could arrange it neatly for me in a uniform format?

einpoklum
  • 12,311

2 Answers2

25

Option 1: With Emacs (in BibTeX mode), placing the cursor at the beginning of an entry and pressing C-v C-Q does bibtex-fill-entry, that can be customized in various ways.

Option 2: Biber has reformatting capabilities:

biber --tool --output_align --output_indent=2 --output_fieldcase=lower <filename>.bib

will produce <filename>_bibertool.bib with similar effects; I've shown some of the possible options. Biber is not limited to reformatting; fields can be removed and other changes are possible, see the manual.

einpoklum
  • 12,311
egreg
  • 1,121,712
4

There are some BibTex utilities on CTAN:
https://www.ctan.org/tex-archive/biblio/bibtex/utils
The following two sound like they will do exactly what you asked for:

matth
  • 12,381
  • I'm having trouble getting those working as part of TexLive. Link? – einpoklum May 06 '15 at 09:02
  • I don't know if these tools are included in the Texlive and/or MikTex distribution. What operating systems are you on? On Ubuntu installation is as easy as sudo apt-get install bibtool. – matth May 06 '15 at 12:30
  • related: http://tex.stackexchange.com/questions/180840/seeking-bibtool-for-windows-binary – matth May 06 '15 at 12:32
  • Windows. But I will say biber, which is included with TeXLive, now works-for-me, so I don't think I'll dig into this too deeply. – einpoklum May 06 '15 at 14:36