[Tex/LaTex] Making global footnotes inside a minipage with hyperref support

countersfootnoteshyperrefminipage

I would like to make footnotes inside a minipage that use the global footnote counters and the hyperref package.

I'm having trouble getting hyperref to make the correct references. I imagine I need to change the Hfootnote counter but I haven't had any luck with that and I'm not sure exactly what's going on. I tried adding a \addtocounter{Hfootnote}{-1} and \stepcounter{Hfootnote} but that didn't help.

Below is a minimal example.

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\noindent\ldots{} main text\footnote{Before minipage} \ldots\par
\fbox{\begin{minipage}{.5\linewidth}
    A footnote to use global footnotes.\footnotemark
    A second global footnote.\footnotemark
\end{minipage}}
\addtocounter{footnote}{-1}
\footnotetext{First global footnote inside minipage}
\stepcounter{footnote}
\footnotetext{Second global footnote inside minipage}
\par
\noindent\ldots{} main text\footnote{After minipage} \ldots\par
\end{document}

Clicking on the first footnote inside the minipage does not yeild the expected result.

Best Answer

I finally figured it out! The short answer is that Hyperref sucks at footnotes.

Thanks to Gonzalo Medina's answer to a similar question I was able to adapt a workaround. I'm new to tex.stackechange so if I can give any more credit to Medina please let me know how.

Below is the working example.

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\noindent\ldots{} main text\footnote{Before minipage} \ldots\par
\makeatletter
\fbox{\begin{minipage}{.5\linewidth}
    A footnote to use global footnotes.\footnotemark\global\let\saved@Href@A\Hy@footnote@currentHref
    A second global footnote.\footnotemark\global\let\saved@Href@B\Hy@footnote@currentHref
\end{minipage}}
\addtocounter{footnote}{-1}
\let\Hy@footnote@currentHref\saved@Href@A 
\footnotetext{First global footnote inside minipage}
\stepcounter{footnote}
\let\Hy@footnote@currentHref\saved@Href@B
\footnotetext{Second global footnote inside minipage}
\makeatother
\par
\noindent\ldots{} main text\footnote{After minipage} \ldots\par 
\end{document}
Related Question