Thursday, November 1, 2007

Bibliography without linebreaks in Latex

I wanted to have a bibliography without any linebreaks in a Latex document so instead of:

[1] A.Person Why everything I do is great, Nat. Ret., 22-55, 11 2007

[2] An.Other Why everything A.Person does sucks, J. Coolness, 34-42, 1, 2008

[3] I.nsert Why including witty puns in journal articles is morally unjustified, J. Boring, 23-32, 23, 2023

I wanted:

[1] A.Person Why everything I do is great, Nat. Ret., 22-55, 11 2007 [2] An.Other Why everything A.Person does sucks, J. Coolness, 34-42, 1, 2008 [3] I.nsert Why including witty puns in journal articles is morally unjustified, J. Boring, 23-32, 23, 2023

All on one line.

Turns out that the bibliography is a list, and each reference is a \item. \item automatically adds a linebreak (and a linespace) at the end of each item. To get round this I change the thebibliography environment to use a 'paralist'. This is a type of list which doesn't adds linebreaks. I also redefine \cite to reference the paralist labels. There are a couple of drawbacks. First \cite{article1,article2} doesn't work anymore, this is a pain but was an acceptable trade off for me. Secondly you need to edit your bbl file (which bibtex outputs) becuase that has linebreaks between the bibitems as well. A quick awk script to remove all the blank lines for the bbl file should do the trick.

Anyway, here's the code I added to my preamble (remember you need \usepackage{paralist} too).
