12

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}

undesired result

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 https://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:

unexpected result

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

1
  • 1
    Be sure to load hyperref after footmisc.
    – Mico
    Commented May 20, 2012 at 23:59

2 Answers 2

10

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

enter image description here

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}
4
  • Unfortunately, it does not work on all cases (see above)
    – koppor
    Commented May 21, 2012 at 8:26
  • code updated to remove skip after each url Commented May 21, 2012 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
    Commented May 23, 2012 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, Commented May 23, 2012 at 16:34
2

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}

enter image description here

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}
2
  • I really want to have the [para] option in place: I want to save space in a paper.
    – koppor
    Commented May 20, 2012 at 23:34
  • @koppor: See the edit.
    – user11232
    Commented May 20, 2012 at 23:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .