16

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?

  • 2
    biber can do it. – Ulrike Fischer Jun 26 '14 at 11:49
  • 1
    Also Emacs can do it. – egreg Jun 26 '14 at 12:25
  • 1
    @egreg: I said utility, not a self-contained operation system... :-) – einpoklum - reinstate Monica Jun 26 '14 at 12:27
  • @egreg an answer? – cmhughes Jun 26 '14 at 14:18
  • @egreg: You don't have to wait that I have time to expand a comment. I really don't mind if someone adds an answer based one of my comments. Btw: Since biber 2.9. you can use hyphens instead of underlines in the options. So output-align etc works too. – Ulrike Fischer Jun 26 '14 at 14:52
20

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.

3

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:

  • I'm having trouble getting those working as part of TexLive. Link? – einpoklum - reinstate Monica May 6 '15 at 9: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 6 '15 at 12:30
  • related: tex.stackexchange.com/questions/180840/… – matth May 6 '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 - reinstate Monica May 6 '15 at 14:36

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.