I'm trying to write some code that lets me use footnotes inside stackrel multiple times in a single equation, and so far this is what I've come up with
\documentclass{article}
\usepackage{hyperref}
\usepackage{xparse}
% --------------------------
\newcounter{stckrelfnotes}
\setcounter{stckrelfnotes}{-1}
%
\newcommand{\tofootnote}[1]{%
\mathrel{\vbox{\offinterlineskip\ialign{\hfil##\hfil\cr$\scriptscriptstyle\footnotemark$\cr\noalign{\kern.05ex}$#1$\cr}}}%
\addtocounter{stckrelfnotes}{1}}
%
\let\oldfootnotetext\footnotetext
\renewcommand{\footnotetext}[1]{%
\oldfootnotetext[\crrctnmbr]{#1}%
\addtocounter{stckrelfnotes}{-1}}
%
\ExplSyntaxOn
\NewExpandableDocumentCommand{\crrctnmbr}{}{
\int_eval:n { \value{footnote} - \value{stckrelfnotes} }
}
\ExplSyntaxOff
% --------------------------
\begin{document}
\footnote{a}
%
\begin{equation}
a \tofootnote{=} b \tofootnote{=} c
\end{equation}
\footnotetext{b}
\footnotetext{c}
%
\footnote{d}
\end{document}
this gets all the numbers right, however the two footnote links inside the equation link to nothing. The log gives me the following warnings:
pdfTeX warning (dest): name{Hfootnote.3} has been referenced but does not exist, replaced by a fixed one
pdfTeX warning (dest): name{Hfootnote.2} has been referenced but does not exist, replaced by a fixed one
which probably means that the relative footnote anchors are not named Hfootnote.3
and Hfootnote.2
. How can I change those anchors so that I get the right links?