# How to break URLs when footnotes are on same line?

Question Footnotes on the same line revealed that it is a good idea to use \usepackage[para]{footmisc}. However, this does not seem to work with URLs:

\documentclass{article}
\usepackage{hyperref}
\usepackage[para]{footmisc}
\begin{document}
test\footnote{\url{http://www.example.org/long-URL/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long}}
\end{document}


The given URL is not wrapped (but footnote 2 and 3 are on the same line). If footmisc is not loaded, the URL is wrapped perfectly. What can I do if I want to use footnotes with URLs next to each other?

More complex example (following answer http://tex.stackexchange.com/a/56706/9075):

\documentclass{article}
\usepackage[para]{footmisc}
\usepackage{hyperref}

\def\myurl#1{\setbox0\vbox{\hsize.5\maxdimen
\url{#1}\par
\global\setbox1\lastbox}\unhbox1 }

\begin{document}

test\footnote{\myurl{http://www.example.org/long-URL/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long}}

ODE\footnote{\myurl{http://ode.apache.org/}}).
SOAP/http\footnote{\myurl{http://www.w3.org/TR/soap12-part2/}}
\end{document}


The output is as follows:

I'd like to have footnote 2 and 3 on the same line

-
Be sure to load hyperref after footmisc. –  Mico May 20 '12 at 23:59

To make it work with para automatically you need a modified version of \url

as noted in the comments, you the first version added parfillskip glue after each url which padded to the end of the line, This version removes that.

\documentclass{article}
\usepackage[para]{footmisc}
\usepackage{hyperref}

\def\myurl#1{\setbox0\vbox{\hsize.5\maxdimen
\url{#1}\par
\setbox0\lastbox
\global\setbox1\hbox{\unhbox0\unskip\unskip\unpenalty}}\unhbox1 }

\begin{document}
test\footnote{\myurl{http://www.example.org/long-URL/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long}}

ODE\footnote{\myurl{http://ode.apache.org/}}).
SOAP/http\footnote{\myurl{http://www.w3.org/TR/soap12-part2/}}
\end{document}

-
Unfortunately, it does not work on all cases (see above) –  koppor May 21 '12 at 8:26
code updated to remove skip after each url –  David Carlisle May 21 '12 at 9:30
Is it possible to reduce the space between the footnotes? For me, there seems to be much space before "2" and "3". –  koppor May 23 '12 at 16:01
TeX doesn't "want" to put a lot of space there, but with the limited number of places it can break a URL it has to over-stretch the space between paras (and complain in the log about underful boxes) You can get a better stretcing and no warnings by adding  \Urlmuskip = 0mu plus 2mu which allows a bit of white space around / and other url break-able characters, –  David Carlisle May 23 '12 at 16:34

If you remove the [para] option for footmisc, every thing works smoothly.

\documentclass{article}
\usepackage{footmisc}
\usepackage{hyperref}
\begin{document}
test\footnote{\url{http://www.example.org/long-URL/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long}}
\end{document}


Edit: If you want to keep the para option for footmisc, we can pass the option [obeyspaces,spaces] to url (loaded by hyperref) and give a space where the line has to be broken. Since there comes an option clash between footmisc, we pass it to the documentclass.

\documentclass[obeyspaces,spaces]{article}
\usepackage[para]{footmisc}
\usepackage{hyperref}
\begin{document}
test\footnote{\url{http://www.example.org/long-URL/long/long/long/long/long/long/long/long/long/ long/long/long/long/long/long}}
\end{document}

-
I really want to have the [para] option in place: I want to save space in a paper. –  koppor May 20 '12 at 23:34
@koppor: See the edit. –  Harish Kumar May 20 '12 at 23:43