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?
Asked
Active
Viewed 4,679 times
20
einpoklum
- 12,311
2 Answers
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.
-
Is biber available with all common distros? Is it part of a package? – einpoklum 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 Jun 27 '14 at 06:50
-
1In emacs, there is the menu item
BibTeX-Edit > Operating on Buffer or Region > Reformat Entrieswhich will deal more than one entry at a time. – Andrew Swann May 05 '15 at 07:08 -
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 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
output-alignetc works too. – Ulrike Fischer Jun 26 '14 at 14:52