Skip to content

Broken hyperlink to \label inside \footnote inside minipage #402

@sim642

Description

@sim642

Consider this document:

\documentclass{article}
\usepackage{float}
\usepackage{booktabs}
\usepackage{hyperref}

\begin{document}

\section{minipage}
\begin{table}[H]
    \begin{minipage}{\linewidth}
    \centering
    \begin{tabular}{ccc}
        \toprule
        X\footnote{\label{minipage}minipage} & \footnote{other} & X\footref{minipage} \\
        \bottomrule
    \end{tabular}
    \end{minipage}
\end{table}

\end{document}

Here the \footref has the correct textual reference to footnote a, but the hyperlink is incorrect.

This seems to because the redefinition of \@mpfootnotetext does not set \@currentHref, while \@footnotetext does.

This workaround seems to work at least in this case:

\long\def\@mpfootnotetext#1{%
    \H@@mpfootnotetext{%
      \ifHy@nesting
        \expandafter\@firstoftwo
      \else
        \expandafter\@secondoftwo
      \fi
      {%
        \expandafter\hyper@@anchor\expandafter{%
          \Hy@footnote@currentHref
        }{\ignorespaces #1}%
      }{%
        \Hy@raisedlink{%
          \expandafter\hyper@@anchor\expandafter{%
            \Hy@footnote@currentHref
          }{\relax}%
        }%
        \let\@currentHref\Hy@footnote@currentHref % fix
        \let\@currentlabelname\@empty % fix
        \ignorespaces #1%
      }%
    }%
  }%

Although maybe there's a reason the two are different.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions