Multiple references to the same footnote with hyperref support - is there a better solution?

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?

-

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]{%
\footnotetext[\thefootnote]{%
\refstepcounter{footnote}\label{#1}%
#2%
}%
$^{\ref{#1}}$%
}

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

%\newcounter{normalfootc}
%\renewcommand{\footnote}[1]{%
%    \footlabel{footsaferefiwontuse\thenormalfootc}{#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}%
}


Hope this helps!

-
Remaining issue: When the reference to the referenced footnote is not placed after that footnote, but another footnote is between referenced footnote and reference, then the in-between-footnote also links to the referenced footnotetext, e.g.: \footlabel{rom}{1} \footnote{2} \footref{rom} writes 1 2 1 but links aim at 1 1 1. This might be OK for the OP, but a warning about this might be appropriate for other users (especially because the cleveref solution does not show this issue). –  Stephen Mar 12 '12 at 17:10

You can use the cleveref package (which is useful in any case) and redefine the reference style for footnotes with a single line. Then you just reference your footnotes (and any other material) using \cref{<label>}.

\documentclass{article}
\usepackage{hyperref}
\usepackage{cleveref}[2012/02/15]% v0.18.4;
% 0.16.1 of May 2010 would be sufficient, but what is the exact day?

\crefformat{footnote}{#2\footnotemark[#1]#3}

\begin{document}
First page, referencing future footnote\cref{second}.

Second paragraph, first footnote\footnote{\label{first}First footnote!}

\pagebreak
Second page, creating the second footnote\footnote{\label{second}Second footnote},
and referencing the first footnote\cref{first}.
\end{document}

-
This generates artefact ?? when using the \cref command on my machine. –  romeovs Feb 2 '11 at 22:36
@romeovs Have you run LaTeX twice? That's usually necessary when using labels and references. –  Jake Feb 2 '11 at 22:37
@Jake Yes I did. There are double ?? in the first run, half of which disappear in the second run. E.g. I get:  future footnote?? 2. –  romeovs Feb 2 '11 at 22:48
@romeovs Is cleveref generally not working on your system? That is, if you remove the line \crefformat{footnote}{#2\footnotemark[#1]#3}, does the error also appear? –  Jake Feb 2 '11 at 23:07
Ok, so, I've figured it out. This solution doesn't work if the footnotes are referenced from a table cell. In such case, this other question is relevant: tex.stackexchange.com/questions/95866/… –  Filipe Correia Mar 6 '14 at 14:34

I found the following to be the easiest to implement:

First sentence.\footnote{\label{footnote-label} footnote content}

Second sentence.\textsuperscript{\ref{footnote-label}}


Since I never use anything but \ref, and I do not mess with LaTeX's counters, hyperref behaves as expected. You could use macros to automate these choices:

\newcommand{\savefootnote}[2]{\footnote{\label{#1}#2}}
\newcommand{\repeatfootnote}[1]{\textsuperscript{\ref{#1}}}

First sentence.\savefootnote{footnote-label}{footnote content}

Second sentence.\repeatfootnote{footnote-label}

-

For completeness' sake: the KOMA-Script classes also have a \footref that works fine with hyperref.

\documentclass{scrartcl}
\usepackage{hyperref}
\begin{document}

Some text\footnote{Some footnote text.\label{fn:first}} and more text with
the same footnote referenced.\footref{fn:first}

Some text\footnote{Some footnote text.\label{fn:second}} and more text with
the both footnotes\footref{fn:first} referenced.\footref{fn:second}

You also can reference\footref{fn:third} the footnote\footnote{Like this.\label{fn:third}}
before the actual footnote.

% let's see if hyperref' works:
\newpage\null
\end{document}


In case you can't or won't use a KOMA-Script class you can load the scrextend package (part of the KOMA-Script bundle) and the functionality anyway:

\documentclass{article}
\usepackage{scrextend}
\usepackage{hyperref}
\begin{document}

Some text\footnote{Some footnote text.\label{fn:first}} and more text with
the same footnote referenced.\footref{fn:first}

Some text\footnote{Some footnote text.\label{fn:second}} and more text with
the both footnotes\footref{fn:first} referenced.\footref{fn:second}

You also can reference\footref{fn:third} the footnote\footnote{Like this.\label{fn:third}}
before the actual footnote.

% let's see if hyperref' works:
\newpage\null
\end{document}

-

cleveref, as proposed by Jake, really solves the problem and is my preferred solution (+1 for it). Just in case that you cannot use it (maybe due to an old version without possibility to update) you can use this replacement :

\documentclass{article}
\usepackage{hyperref}

\makeatletter
\newcommand{\footnoteref}[1]{%
% requires a label to be present in the footnote to be referenced!
\ifHy@hyperfootnotes% option hyperfootnotes=true
\hbox{\hyperref[#1]{%
% once upon a time this was not "#1" but "\footnote@reference",
% but somewhere something changed at some time
\@textsuperscript {\normalfont \ref*{#1}}}}%
\else% option hyperfootnotes=false
\hbox{\@textsuperscript {\normalfont \ref*{#1}}}%
\fi%
\hbox{\@textsuperscript {\normalfont \ref{#1}}}%
}%
}
\makeatother

\begin{document}
First page, referencing future footnote\footnoteref{second}.

Second paragraph, first footnote\footnote{\label{first}First footnote!}

\pagebreak
Second page, creating the second footnote\footnote{\label{second}Second footnote},
and referencing the first footnote\footnoteref{first}.

\pagebreak
Last paragraph\footnote{last footnote}.

\end{document}


The references look exacly like the ones set by hyperref, and if hyperref is used with hyperfootnotes=false or hyperref is not used, the references are just placed but not hyperlinked (but also cleveref would handle this!).

-

To repeat the footnote mark is in general not a good idea, because by convention the footnote marks must appear on the same page as the footnote itself. There is no way you can ensure this to happen, because TeX breaks the page where it wants. Endnotes are more appropriate here.

Where repeated footnote marks are often used is inside tables, but there you need a lot of fiddling because the normal footnote mechanism does not work in inner environments such as tables, equations, etc.

Below is an example that will do what you requested. It is the basic mechanism that I have build into the refstyle package.

Please note that a minipage has its own footnote mechanism that is reset every time it is called. Also note that the label must be inside the footnote itself, because it is not visible outside it.

\documentclass{article}
\usepackage{hyperref}
\makeatletter
\newcommand{\reffnmark}[1]{%
\begingroup
\unrestored@protected@xdef\@thefnmark{\ref{#1}}%
\endgroup
\@footnotemark}
\makeatother

\begin{document}
\section{First}

This is a footnote test\footnote{first footnote\label{fn:first}}\par
This is a second footnote test\footnote{second footnote\label{fn:sec}}\par
This is a footnote mark\reffnmark{fn:first} link to footnote~\ref{fn:first}.\par

\fbox{\begin{minipage}{0.5\hsize}
This is a footnote test in a mini page\footnote{first footnote\label{fn:mp}}.\par
This is a footnote mark\reffnmark{fn:mp} link to footnote~\ref{fn:mp}
\end{minipage}}
\end{document}

-
There is a problem with this solution: The references generate two hyperlink areas i.stack.imgur.com/gdT7q.png While clicking into the upper left/inner area jumps to the correct footnotetext, clicking into the lower right/outer area jumps to the beginning of the document. The log-file says: pdfTeX warning (dest): name{Hfootnote.5} has been referenced but does not exist, replaced by a fixed one (same for Hfootnote.3) –  Stephen Mar 12 '12 at 17:09
"To repeat the footnote mark is in general not a good idea" But this is really common for affiliations: Smith, A. ^1, Miller, B. ^2, Williams, C. ^1 1 Institute for Research on Footnotes, A-town. 2 Footnotes Reasearch & Developement, Inc., B-town. (especially if there is a list of 20 authors with 14 affiliations, and some of the authors have even more than one affiliation.) –  Stephen Mar 12 '12 at 17:09