5

Every time someone post biblatex bib-file entries, the various fields (author, title, year, journaltitle, etc) are all neatly aligned with an equal sign-column in the middle.

I would like my own bib-file to be that neat, but I cannot find any information about this. For an example a not-so-neat bib-file, see the added image.

I appreciate any help!

Anders

Example of not-so-neat bib-entries

8
  • 2
    Welcome to TeX SE! I just use tabs in my .bib files to keep things more-or-less aligned. I don't think there's any particular trick here unless you editor can impose that sort of order for you ;).
    – cfr
    Apr 19, 2014 at 16:07
  • 2
    In emacs, you can just highlight the entry, and do M-x align-regexp then = and return ...
    – PLK
    Apr 19, 2014 at 16:13
  • 3
    It depends on what program you use for managing the data.
    – egreg
    Apr 19, 2014 at 16:24
  • 2
    You could also try bibtool a utility tool designed to modify .bib files, it seems to offer quite some options to align the keys, see §A.5. Parsing and Pretty Printing, pp. 24-28, esp. pp. 25 sq. of the manual. There also is bibclean (--align-equals is probably what you are looking for).
    – moewe
    Apr 19, 2014 at 17:23
  • 2
    The bib-file management tool JabRef does it automatically.
    – doncherry
    Apr 19, 2014 at 17:50

3 Answers 3

5

You can use Sublime Text and the alignment plugin:

demo of alignment

With this plugin, you can select the bib text entry, press Ctrl + Alt + a and the plugin will align the text at =.

I have written down some more information about sublime text in my blog. Sublime Text is available for free for unlimited testing for unlimited time for Windows, Mac and Linux.

This will also work to align equations (at &).

0
4

You can use the bibliography management tool JabRef (starting with version 2.10). Use the setting Preferences⇒File⇒Field saving options⇒Start field contents in same column. Just opening and saving the file will align the equals signs.

Before:

before

After:

after

I’m not sure, however, what determines the number of spaces before the equals sign. Also, as you can see, JabRef sorts the fields according to what it deems obligatory and optional fields, and secondly alphabetically. I’m not entirely content with that functionality, but then again, if you’re using JabRef, you won’t be fiddling with the raw bib files too much anymore at any rate since you have the comfortable front-end for editing your bibliography file, as you remarked yourself in your answer about BibDesk.

1

To answer my own question, using BibDesk kind of removes the need of an aligned bib-file, given that I add all entries in BibDesk and basically edit all my references in BibDesk.

Since I am LaTeX-ing on OSX, BibDesk may be the best option in that it removes the need to be in the tex editor at all.

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.