# Clickable Table Footnote

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}

• Footnotes in floats are not really a good idea. You better create table notes with »threeparttable«. – Thorsten Donig Nov 28 '10 at 13:13
• Do any of the answers here help? tex.stackexchange.com/questions/1583/footnotes-in-tables – Seamus Nov 28 '10 at 14:49
• Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count. This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). Also upvoting an answer or two is appreciated. – Stephen Mar 22 '12 at 19:23

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}

\let\Hy@footnote@currentHref\saved@Href@B
\footnotetext{This is B}
\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.

You can use the tablefootnote package (loaded after hyperref) and in the table \tablefootnote instead of \footnote. There is no optional parameter to the command, but you do want automatic numbering if I understand your question right.

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

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

\begin{table}[h!]
\centering
\begin{tabular}{|r|r|r|}
\hline
A\tablefootnote{Test!} & B\tablefootnote{This is B} & C\tablefootnote{This is C}\\
\hline
123 & Tim & Jane\\
\hline
456 & Tom & Jung\\
\hline
\end{tabular}
\caption{A table}
\end{table}

This is a another clickable footnote\footnote{Now you clicked me!}.

\newpage

To test the hyperlinks it is very useful to have a second page in the document!

\end{document}

• Already i have given the solution for this in the title: "footnote in the column name of a table" – Mu30 murugans2katgmail Mar 22 '12 at 10:54
• @S.Murugan: Your answer tex.stackexchange.com/questions/46602/… is dated Mar 9 2012 at 14:49, but my answer here was given Feb 12 2012 at 14:38, and in my humble opinion 2012/02/12 is before 2012/03/09. Or do I misunderstand your comment? – Stephen Mar 22 '12 at 19:19
• @S.Murugan: "By chance" at the same time you gave your comment my answer was downvoted. In case you are the downvoter, I do not understand this: You are using this approach in an answer of your own, tex.stackexchange.com/questions/46602/…, but downvote another, earlier answer with this approach? It would be nice if you could explain this. – Stephen Mar 22 '12 at 19:40
• @S.Murugan and your answer at tex.stackexchange.com/questions/46602/… is obviously copied from my answer tex.stackexchange.com/a/35328 of Nov 18 '11. – Stephen Mar 22 '12 at 20:41

I’m using the following technique for having multiple references to the same footnote, with hyperref, combining advice from its documentation and several posts here:

\newcommand{\Hair}{\kern.16667em}
[…]
Falls hierbei Fehler auftauchen prüfen Sie […] die
Logs\Hair\textsuperscript{\ref{fn:tomcatlogs}}.
[…]
Prüfen Sie ggfs. die Logausgaben\Hair\footnote{\label{fn:tomcatlogs}in
\texttt{/var/log/tomcat7/catalina.out}}, […]


As you can see, this makes it easily possible to reference a footnote multiple times once it has been defined anywhere in the document, even later. This is important because footnotes cannot be defined (with \footnote) inside tables or minipages.

Now, I thought I could simply define the body of a footnote with a line like this:

\stepcounter{footnote}\footnotetext{\label{fn:foo}foobar}%


Unfortunately, while referencing this footnote inside a table works, it’s not hyperlinked because hyperref only applies to \footnote but not the split \footnotemark + \footnotetext. So, what we really want is to call \footnote but not render its output.

Easier said than done. But we can temporarily redefine the command that actually sets the mark into the text – \@makefnmark – to nothing. That works, but it requires a paragraph or it will create one, so you would have to do something like:

[…]
\end{tabular}

Some paragraph here.\hyperfootnotetext{\label{fn:foo}foobar}\hyperfootnotetext{…}


As you can see, that quickly becomes illegible, especially with multiple of them. So I tried to temporarily prevent leaving vmode… except, the code still tries to set the (empty) fnmark as hyperlink to the footnote, which only works in horizontal mode. Meh. At this point I was about to call it a day…

… except I found out that we can temporarily prevent setting hyperlinks, too, without giving up the ability to link from a footnote to another.

## SSCCE

This example shows how to use footnotes from tables, multiple times, with hyperlinks to the footnotes as well as hyperlinks in the footnotes themselves, with the ability to declare those footnotes outside of any paragraphs:

\documentclass{scrartcl}
\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
\usepackage{mwe}
\RequirePackage[pdftex]{hyperref}
\hypersetup{
urlcolor = blue,
}

% em dash
\def\dash{\unskip\kern.16667em\textemdash\penalty\exhyphenpenalty\hskip.16667em\relax}
% for footnotes
\newcommand{\Hair}{\kern.16667em}

\makeatletter%
% \hyperfootnotetext is what \footnotetext is supposed to be:
% like \footnote except not rendering anything (it will not
% generate a paragraph if you append % to all lines)
\newcommand\hyperfootnotetext[1]{%
% new local scope
{%
% temporarily redefine this macro to empty
\renewcommand{\@makefnmark}{}%
% temporarily prevent leaving vmode
\renewcommand{\leavevmode}{}%
% this also means we cannot create a(n empty) hyperlink
% call the original \footnote macro
\footnote{#1}%
% exit the local scope with the redefined macro
}%
% end of command
}%
\makeatother%

\begin{document}

\section{First page}\label{sec:first}

These are the system requirements:

\begin{tabular}{| r || l | l | l |}\hline
& minimum    & recommended   & maximum\\\hline\hline
Operating System   & Debian 7   & Debian 7 or 8 & Debian unstable\Hair\textsuperscript{\ref{fn:req-nolimit}}\\\hline
Webserver          & Apache 2.2 & Apache 2.2    & Apache 2.4\Hair\textsuperscript{\ref{fn:req-notmore}}\\\hline
Java Runtime       & OpenJDK 7  & OpenJDK 8     & OpenJDK 8\Hair\textsuperscript{\ref{fn:req-notmore}}\\\hline
Application Server & Tomcat 7   & Tomcat 7      & Tomcat 7\Hair\textsuperscript{\ref{fn:req-nonewer}}\\\hline
\end{tabular}

% note no paragraph here before next section!

\hyperfootnotetext{\label{fn:req-nolimit}%
no practical limitation}%
\hyperfootnotetext{\label{fn:req-notmore}%

\section{Second half}\label{sec:second}

Page break upcoming.

\newpage

Some systems were not tested\Hair\footnote{\label{fn:didnot}… or
did not exist at the time of this writing}.

\end{document}


Application note: you will most likely have your \hyperfootnotetext calls directly below the table (unless you’re re-using a footnote defined elsewhere) to get them ideally placed on the same page.

Side note: originally I had my \hyperfootnotetext reimplement the original \footnote except inlining \@footnotemark minus its \@makefnmark call… this would have gotten old quick… finally I found you can temporarily redefine commands inside other commands for their duration only. (I don’t understand yet why setting hyperlinks inside footnote texts still works in my example, but I’m happy about that.)

ObNote: this ought to work for minipages, too.

• I can't thank you enough, not only solves this my problem in an elegant way, but it adds the feature of not having to write the footnote text inside the table in the code, which makes it very well-arranged. Well done! – dessert Mar 23 '16 at 10:40