79

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?

escalator
  • 263

11 Answers11

93

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}
Stephen
  • 14,890
Jake
  • 232,450
  • 2
    This generates artefact ?? when using the \cref command on my machine. – romeovs Feb 02 '11 at 22:36
  • 1
    @romeovs Have you run LaTeX twice? That's usually necessary when using labels and references. – Jake Feb 02 '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 02 '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 02 '11 at 23:07
  • Yes, that could be the problem. – romeovs Feb 03 '11 at 07:30
  • @romeovs You're probably using an old version of cleveref, the feature for referencing footnotes was only introduced in version 0.16.1 in May 2010 (see the announcement) – Jake Feb 03 '11 at 10:03
  • Unfortunately that might not be the whole story. I'm using version 0.18.5, from 2012/03/07, but still get the ?? in place of the footnote reference. – Filipe Correia Mar 06 '14 at 14:15
  • 9
    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: http://tex.stackexchange.com/questions/95866/multiple-references-to-the-same-footnote-inside-a-table-environment – Filipe Correia Mar 06 '14 at 14:34
  • hi. When loading \usepackage[french]{babel}, the link is correct but the text displayed is wrong, spitting out chapter or section it is inside. Do you know a workaround ? It is ok in english...I'm using exactly your example as a test, so no ":" in labels. – Napseis Jan 02 '16 at 15:12
  • @Napseis: I don't, sorry. I think it would be best if you could open a new question for this. – Jake Jan 02 '16 at 15:13
  • I'm not sure, but after using the package cleveref, it results in errors with the euqation environment. Any idea? – Roger Yau Jun 01 '17 at 02:28
  • 1
    @Jake With Cleveref dated 2013/12/28 (I think), the line \crefformat{footnote}{#2\footnotemark[#1]#3} is not only unnecessary but causes in fact an error. Without it, it just works beautifully! – schremmer Jan 04 '18 at 20:36
  • This doesn't work with footmisc package. – facetus Feb 20 '21 at 23:59
  • This worked for me! – RainRain Dec 15 '21 at 20:31
  • In case another french writing user has the same issue as @Napseis (and of course me), they asked their question and the answer is here: https://tex.stackexchange.com/a/285617/56823 (And I can confirm that as said above, no need to define the format anymore) – Archange Sep 24 '23 at 19:04
60

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}
Werner
  • 603,163
Uriel CP
  • 601
  • 11
    So much simpler than the other complicated choices, thank you! – J M Jun 28 '16 at 18:46
  • 1
    To mimic the code of \footnote, I believe that \textsuperscript should be followed by \normalfont. Also, to prevent weird breakage, \label should be \protect\label. – Michaël Jan 20 '17 at 16:00
  • It results in a compressed reference box due to the command \textsuperscript. I tried to replace with $^{\ref{footnote-label}}$, but it couldn't be recognized by Tex with error "too many }'s". Can anybody help? – Roger Yau Jun 01 '17 at 02:22
  • It does not seem to cooperate with package hyperref. The reference is not clickable in PDF. – Piotr Siupa Apr 09 '18 at 12:51
  • This approach mostly works for me (I should mention that I'm trying to do this within a minipage), except that with hyperref all of the explicit \textsuperscript marks link to the location of the first explicit \textsuperscript mark. – JacobEvelyn May 02 '18 at 01:26
  • If the newtxtext package is used then the footnotes look a little bit different from \textsuperscript, in that case {\sustyle\ref{footnote-label}} should be used (note the outer {} to put \sustyle in a group). – Marijn Dec 17 '23 at 15:55
20

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!

Stephen
  • 14,890
romeovs
  • 9,102
  • 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
  • There's other problems, for example it does not work with package paracol and \footnotestyle{p}. But using cleveref as suggested in Jake's answer does ... I won't downvote this as there's plain contexts where this will work. The upvote goes to Jake though ;-) – takrl Dec 19 '15 at 08:01
15

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}
cgnieder
  • 66,645
9

An old question, but I just found out that a simple

\newcommand{\footref}[1]{\textsuperscript{\ref{#1}}}

will suffice:

\documentclass{article}
\usepackage{hyperref}

\newcommand{\footref}[1]{\textsuperscript{\ref{#1}}}

\begin{document}

Some footnote.\footnote{Text.\label{footnote}} And referencing the same footnote.\footref{footnote}

\end{document}
5

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!
\ltx@ifpackageloaded{hyperref}{% hyperref package loaded
  \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%
}{% hyperref package not loaded
    \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!).

Stephen
  • 14,890
3

Not sure if packages have been updated but footmisc works fine with hyperref in this example:

\documentclass{article}

\usepackage{footmisc} \usepackage{hyperref}

\begin{document}

Text with the first footnote\footnote{\label{footnote1}Footnote 1} and text with the second footnote\footnote{Footnote 2}.

In this paragraph we have a reference to the first footnote\footref{footnote1}.

\end{document}

Cyker
  • 667
2

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}
Stephen
  • 14,890
Danie Els
  • 19,694
  • 2
    There is a problem with this solution: The references generate two hyperlink areas http://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
  • 1
    "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
2

The footmisc package works like charm for multiple hyperref's to same foot note, it doesn't matter if you use numbers or symbols for your foot notes.

\documentclass{article}

\usepackage{footmisc} % Numbers. %\usepackage[symbol]{footmisc} % Symbols. \usepackage{hyperref}

\begin{document}

Text with future reference\footref{note}. Text that creates the reference\footnote{\label{note}Text of the reference}. Text that references the same note\footref{note}.

\end{document}

1

do not change:

\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}
Zarko
  • 296,517
Dennis
  • 11
  • 1
    Welcome to TeX.SE! please do not only post code, explain what it does and how it solved the given problem ... – Mensch Jan 07 '17 at 15:30
1

The fixfoot package is another interesting solution. It defines footnotes with possibly reoccurring text:

\DeclareFixedFootnote{\prooflater}{This theorem will be proved later}
\DeclareFixedFootnote*{\sic}{\emph{sic}}

You can use the commands whereever \sic you want\prooflater. In case the footnote would be placed \sic on the same page, it won't be printed twice, but still referenced twice.

The starred version uses xspace to ease use of the command. Otherwise, one had to write \sic{} text.

koppor
  • 3,252