[Tex/LaTex] Clickable Table Footnote

footnoteshyperreftables

I'm trying to have some clickable footnotes within tables. I tried using \footnote{}, it does create a link but there's no footnote text associated with it. \footnotemark[number] along with \footnotetext[]{} does create a fotenote but then there's no hyperlink. (I would like to make it clear that I'm trying to have footnotes at the bottom of the page and not footnotes within the table.)

Here's a small code snippet:

\documentclass{report} 
\usepackage{hyperref}
\begin{document}

\begin{table}[h!]
    \centering
    \begin{tabular}{|r|r|r|}
        \hline
        A\footnote{Test!} & B\footnotemark[4] & C\footnotemark[5]\\
        \hline
        123 & Tim & Jane\\
        \hline
        456 & Tom & Jung\\
        \hline
    \end{tabular}
    \caption{A table}
\end{table}

This is a clickable footnote\footnote{You clicked me!}.

\footnotetext[4]{This is B}
\footnotetext[5]{This is C}

\end{document}

Best Answer

From the hyperref README, Section 8 "Hints", p. 26:

The footnote support is rather limited. It is beyond the scope to use \footnotemark and \footnotetext out of order or reusing \footnotemark. Here you can either disable hyperref’s footnote support by "hyperfootnotes=false" or fiddle with internal macros [...]

P. 26-27 give some "nasty examples"; I've used the second one as groundwork to modify your code example. This is what I came up with:

\documentclass{report} 

\usepackage{hyperref}

\begin{document}
\makeatletter

\begin{table}[h!]
    \centering
    \begin{tabular}{|r|r|r|}
        \hline
        A & B\footnotemark\global\let\saved@Href@B\Hy@footnote@currentHref & C\footnotemark\global\let\saved@Href@C\Hy@footnote@currentHref \\
        \hline
        123 & Tim & Jane\\
        \hline
        456 & Tom & Jung\\
        \hline
    \end{tabular}
    \caption{A table}
\end{table}

\addtocounter{footnote}{-1}%
\let\Hy@footnote@currentHref\saved@Href@B
\footnotetext{This is B}
\addtocounter{footnote}{1}%
\let\Hy@footnote@currentHref\saved@Href@C
\footnotetext{This is C}

This is a clickable footnote\footnote{You clicked me!}.

\end{document}

By the way I agree with Thorsten Donig that footnotes in floats are not a good idea.