[Tex/LaTex] Multiple references to the same footnote with hyperref support – is there a better solution

footnoteshyperref

According to the Latex wikibook the workaround for having multiple references to the same footnote with hyperref support is this:

\footnote{This is the footnote}\addtocounter{footnote}{-1}\addtocounter{Hfootnote}{-1}

I could of course simply wrap this in a new command, but I wonder if there is any package that handles this elegantly, preferably with an option to refer to footnotes using labels. The way proposed above also screws up if there are other footnotes in between. The \footref command from the footmisc package does something like that, but it does not have full hyperref support. Does anyone know of a package that can do this?

Best Answer

I'm not sure if this is what you're asking for, but I think these macros do what you want:

\documentclass{article}
\usepackage{hyperref}

\newcommand{\footlabel}[2]{%
    \addtocounter{footnote}{1}%
    \footnotetext[\thefootnote]{%
        \addtocounter{footnote}{-1}%
        \refstepcounter{footnote}\label{#1}%
        #2%
    }%
    $^{\ref{#1}}$%
}

\newcommand{\footref}[1]{%
    $^{\ref{#1}}$%
}

%\newcounter{normalfootc}
%\renewcommand{\footnote}[1]{%
%    \footlabel{footsaferefiwontuse\thenormalfootc}{#1}%
%    \addtocounter{normalfootc}{1}%
%}

\begin{document}

This is a sentence with a footnote\footlabel{rom}{this is the adapted footnote} in it. 
This second sentence points to the same footnote,\footref{rom} so you don't have 
to write it all over again. As you can see, the macro's work in conjuncture with 
the normal\footnote{this is a normal footnote} footnote. 
Though there is a small discrepancy in how the links are displayed.

\end{document}

The macro \footlabel{<label>}{<foonote text>}creates the footnote and gives it a label that can later be accessed by using \footref{<label>}.

There's one slight problem with these macro's though: they produce a slightly different "box" for the hyperref link (default is a red box) which might be unwanted if you're aiming for ultimate consistency. This won't be a problem if you have already redefined your hyperref link style to be something else. You could also use the \footlabel command without any label argument for all your footnotes (even the normal ones) to make everything consistent again.

This in the preamble makes it consistent again:

\newcounter{normalfootc}
\renewcommand{\footnote}[1]{%
    \footlabel{footsaferefiwontuse\thenormalfootc}{#1}%
    \addtocounter{normalfootc}{1}%
}

Hope this helps!