Too long website as footnote results in Overfull \hbox

I have a very long website as footnote and I get a warning message Overfull \hbox.

This is the website:

\footnote{Vgl.: http://www.bmwi.de/DE/Themen/Energie/Energiedaten-und-analysen/Energiedaten/energiegewinnung-energieverbrauch.html}


If I insert allowbreak like below, I get another warning message Underfull \hbox

\footnote{Vgl.: http://www.bmwi.de/DE/Themen/Energie/Energiedaten-und-analysen/Energiedaten/\allowbreak energiegewinnung-energieverbrauch.html}


Can someone tell me which is the best way to handle this?

• Have you tried the url package? \usepackage{url}...\url{http://www.long.path/here} – Sean Allred May 14 '14 at 17:07

For long URLs use:

\usepackage[hyphens]{url}
...

\footnote{\raggedright Vgl.: \url{http://www.bmwi.de/DE/Themen/Energie/Energiedaten-und-analysen/Energiedaten/energiegewinnung-energieverbrauch.html}}

• I would only do that if you're really really sure that the reader won't be irritated by the hyphen at the end of a line (like when you explain the line breaking behaviour at one point in the document). I think the author of the url package made a really smart choice when he decided not to allow line breaks after hyphens. – Christian May 14 '14 at 21:14

There's the url package that has special line breaking for URLs and also automatically adds a hyperlink to the PDF if you also use the hyperref package. Just pass your URL to the \url macro:

\footnote{Vgl.: \url{http://www.bmwi.de/DE/Themen/Energie/Energiedaten-und-analysen/Energiedaten/energiegewinnung-energieverbrauch.html}}

• If I use this I get a too large space between Vgl.: and the beginning of the link, like shown here: directupload.net/file/d/3622/glrperij_png.htm – DatamineR May 14 '14 at 17:25
• @RStudent You probably also get the "underfull \hbox" error as you did for your manual fix. The sad truth is that there just aren't enough opportunities for line breaks to typeset this with a fixed line width. URLs are notoriously tricky here. What I would do in your case is to set the whole footnote as \raggedright or \RaggedRight (from the ragged2e package ... shouldn't do much of a different here). – Christian May 14 '14 at 17:42