# Footnotes split on two pages with hyperlink

Considers the following MWE

\documentclass{article}
\usepackage[paperwidth=5cm,paperheight=5cm]{geometry}
\usepackage{hyperref}

\begin{document}
a\footnote{\href{http://texnique.fr}{Lorem ipsum dolor sit amet Lorem ipsum dolor sit ametLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco}}aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa
\end{document}


The hyperlink is also set to the main text of the footnote, and not only on the footnote text.

Any idea to solve this issue?

• I don't think \label{A} has anything to do with your problem, am I right? But, I agree, this is a weird behavior… – Clément Jan 5 '17 at 16:12
• It's known that hyperref is not able to create hyperlinks that straddle two pages. – egreg Jan 5 '17 at 16:19
• @Clément it's not so weird as there is a \pdfstartlink on page 1 and a \pdfendlink at the bottom of page 2, so the whole of page 2 is a link. You may think of the text body and the footnotes as separate streams but that's not how pdf sees them. While it is easy to see what goes wrong it is hard to fix as the split insertion happens deep in tex so there is no easy way to customise it to insert a \pdflink at the end of page 1 and \pdfstartlink at the start of the split footnote on page 2. – David Carlisle Jan 5 '17 at 16:27
• @egreg : not by me! – Clément Jan 5 '17 at 16:34
• @Clément: corrected. – Maïeul Jan 5 '17 at 16:49

It's not so weird as there is a \pdfstartlink on page 1 and a \pdfendlink at the bottom of page 2, so the whole of page 2 is a link. You may think of the text body and the footnotes as separate streams but that's not how pdf sees them. While it is easy to see what goes wrong it is hard to fix as the split insertion happens deep in tex so there is no easy way to customise it to insert a \pdfendlink at the end of page 1 and \pdfstartlink at the start of the split footnote on page 2.

One workaround is not to allow split hyperlinks, but to link each word separately so the footnote can still split. Not allowing words to break has some effect on the typesetting of course but may be acceptable.

The following has two versions one commented out has the white space inside the link so the full footnote acts like a single active area, but white space does not stretch. the second has the normal stretchy wordspace in the footnotes but the spaces are not hyperlinked so it is obvious to the reader that each word links separately.

\documentclass{article}
\usepackage[paperwidth=5cm,paperheight=5cm]{geometry}
\usepackage{hyperref}
\makeatletter
\def\xhref#1#2{\def\tmp{#1}\xxhref#2 \^ }
\def\xxhref#1 {%
\ifx\^#1\expandafter\@gobble\else\expandafter\@firstofone\fi
%  {\mbox{\href{\tmp}{#1} }\linebreak[0]\xxhref}}
{\mbox{\href{\tmp}{#1}} \xxhref}}
\makeatother
\begin{document}
a\footnote{\xhref{http://texnique.fr}{Lorem ipsum dolor sit amet Lorem ipsum dolor sit ametLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco}}aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa
\end{document}


• You told me what I was afraid to read. – Maïeul Jan 5 '17 at 16:49
• should not be possible to have a macro, called in the output routine, which 1) will stop the hyperlink 2) store it value to a macro X 3) that macro will be automatically detected on the output routine when the footnote will be inserted – Maïeul Jan 5 '17 at 16:53
• ps: I ask seriously the question, but I am not sur of my idea – Maïeul Jan 5 '17 at 16:53
• @Maïeul basically no. In the output routine you see the split footnote box but you do not know (and can not look) whether there is a hyperlink in that box. – David Carlisle Jan 5 '17 at 16:57