## Wednesday, 24 March 2010

### Breaking URLs in BibTeX

Here's a work-around for a sticky problem when citing URLs in LaTeX documents.

My problem manifested itself in ugly URLs in my bibliography which did not break over multiple lines, causing underfull hboxes all over the shop: the line of text preceding the URLs had 5 words spread horridly across the page.

I tried various work-arounds found via google but the one that eventually solved my problem was found here in "BibTeX tips and FAQ" by M. Shell and D. Hoadley.

My preamble contains the following:
\usepackage{url}
\usepackage[ps2pdf, pagebackref]{hyperref}

And I cite all my URLs in BibTeX like this:
\url{http://morecakelessfish.blogspot.com/}

I like to compile into pdf by using dvi2ps then ps2pdf otherwise I seem to have some issues with offset bounding boxes in my pyxplot .eps graphics. Despite calling the url package in my references (see example above), my URLs still weren't breaking. Apparently this is a problem when going via dvi after including the hyperref package. The problem was solved by including breakurl.sty AFTER the hyperref package in my preamble thusly:

\usepackage{url}
\usepackage[ps2pdf, pagebackref]{hyperref}
\usepackage{breakurl}

Jobs a good'un.