[Tex/LaTex] Labeling a Footnotemark

cross-referencingfootnotesnumbering

Is there a way to label a \footnotemark instance (without redefining the \footnotemark macro)? Labeling the \footnotemark has no effect (it labels whatever environment the command is invoked from) and labeling its corresponding \footnotetext is not guaranteed to produce the correct number (it merely returns the current value of the default footnote counter). See below:

    \documentclass{article}
    \usepackage[colorlinks=true,urlcolor=red,hyperfootnotes=false]{hyperref}
    \begin{document}
    This text is footnoted\footnotemark\label{fnm:1} \footnotemark\label{fnm:2}
    \footnotetext{Footnote `1'\label{fnt:1}.}%
    \footnotetext{Footnote `2'\label{fnt:2}.}%

    The numbers of the labels: %
    \{\ref{fnm:1}, \ref{fnt:1}, \ref{fnm:2},  \ref{fnt:2}\}

    The sequence should read: \{1, 1, 2, 2\} 
    \end{document}

Output:

enter image description here

Labeling a \footnote is trivial as one can simply call the \label command from within the footnote environment. However, LaTeX does not appear to support labeling of a \footnotemark. Please advise if there is an efficient solution to label a \footnotemark. Thank you.

Best Answer

\footnotemark executes \stepcounter{footnote} by default, which does not allow proper referencing. If you want to label a footnote, you need to use \refstepcounter{footnote}. As such, you would need to patch \footnotemark or do other trickery in order to obtain the correct result. \footnotetext on the other hand, has no counter associated with it and therefore cannot be referenced in the same way.

enter image description here

\documentclass{article}
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
% Patch \footnotemark to provide a label that can be referenced.
\patchcmd{\footnotemark}{\stepcounter{footnote}}{\refstepcounter{footnote}}{}{}
\usepackage[colorlinks=true,urlcolor=red,hyperfootnotes=false]{hyperref}% http://ctan.org/pkg/hyperref
\begin{document}
This text is footnoted\footnotemark\label{fnm:1} \footnotemark\label{fnm:2}
\footnotetext{Footnote `1'\label{fnt:1}.}%
\footnotetext{Footnote `2'\label{fnt:2}.}%

The numbers of the labels: %
\{\ref{fnm:1}, \ref{fnt:1}, \ref{fnm:2},  \ref{fnt:2}\}

The sequence should read: \{1, 1, 2, 2\} 
\end{document}

In order to adequately reference a \footnotetext with the same marker as some \footnotemark, you need to be able to pass an expandable reference of that marker to the specific \footnotetext's optional argument. This is the technique that causes hyperref incompatibility in Nested footnotes.