hyperref
hyperref copied to clipboard
footmisc 2011/06/06 v5.5b and hyperref's option hyperfootnotes=false
This was originally posted here: https://github.com/FrankMittelbach/fmitex/issues/5#issue-383991035 but I think it really should be resolved from the hyperref side ...
The issue was brought up by Axel Berger in the German-language usenet-newsgroup de.comp.text.tex in the discussion with subject "Fussnoten widerholen" :
When loading both the package footmisc and the package hyperref, some problems arise:
With hyperref's option hyperfootnotes=true, the macro \footref will deliver a hyperlink where the measurements of the clickable area is considerably smaller than the clickable area of hyperlinks that come into being due to \footnote-commands.
With hyperref's option hyperfootnotes=false, the macro \footref will disobey the hyperref-option and deliver such a hyperlink anyway.
Therefore in case of the hyperref-package being loaded I suggest having the \footref-command
- check for the switch
\ifHy@hyperfootnotes - not place the hyperlink inside the footnotemark (as happens when simply applying the
\ref-command within\@thefnmark) but having the\footref-command apply the starred-variant of the\ref-command within\@thefnmark(which does not deliver a hyperlink) and wrap a call to the\hyperref- macro around the footnote-mark when it gets paced:
In the above-mentioned usenet-discussion I suggested the following patch:
\documentclass{article}
\usepackage{footmisc}
%\usepackage{hyperref}
\usepackage[hyperfootnotes=false]{hyperref}
\makeatletter
\@ifpackageloaded{hyperref}{%
\renewcommand\footref[1]{%
\begingroup
\unrestored@protected@xdef\@thefnmark{%
\ref*{#1}%
}%
\endgroup
\ifHy@hyperfootnotes
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
{\hyperref[#1]{\strut\H@@footnotemark}}{\@footnotemark}%
}%
}{}%
\makeatother
\begin{document}
argument of the footnote command that is being
labelled\footnote{Note text\label{fnlabel}}
potato head\footref{fnlabel}
\end{document}
I quite agree with your sentence that "hyperref cuts across that many packages and therefore does a huge amount of patching", but couldn't we instead of adding more to the mount try to communicate throught some "API"? E.g. something like this (I'm not picky about the actual code, that's only a fast shot):
\documentclass{article}
\usepackage{footmisc}
%\usepackage{hyperref}
\usepackage[hyperfootnotes=false]{hyperref}
\makeatletter
%in footmisc:
\providecommand\hypAPI@@footnotemark@n[1]{\@footnotemark}
\providecommand\hypAPI@@refnolink@n[1]{\ref{#1}}
\renewcommand\footref[1]{%
\begingroup
\unrestored@protected@xdef\@thefnmark{%
\hypAPI@@refnolink@n{#1}%
}%
\endgroup
\hypAPI@@footnotemark@n{#1}%
}%
%in hyperref
\def\hypAPI@@refnolink@n#1{\ref*{#1}}
\ifHy@hyperfootnotes
\def\hypAPI@@footnotemark@n#1{\hyperref[#1]{\strut\H@@footnotemark}}
\fi
\begin{document}
argument of the footnote command that is being
labelled\footnote{Note text\label{fnlabel}}
potato head\footref{fnlabel}
\end{document}