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?
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.
-
Is biber available with all common distros? Is it part of a package? – einpoklum - reinstate Monica Jun 26 '14 at 22:33
-
@einpoklum It has been for some years, you need to issue that command from the command line. – egreg Jun 26 '14 at 22:36
-
1It's not installed by default with MiKTeX 2.9; but it does come as a package. – einpoklum - reinstate Monica Jun 27 '14 at 6:50
-
In emacs, there is the menu item
BibTeX-Edit > Operating on Buffer or Region > Reformat Entries
which will deal more than one entry at a time. – Andrew Swann May 5 '15 at 7:08 -
biber works for me. Although I don't like it's default alignment. – einpoklum - reinstate Monica May 6 '15 at 9:11
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 -
-
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
output-align
etc works too. – Ulrike Fischer Jun 26 '14 at 14:52