6

Which package should I use for proper footnote handling in tabu tables? I thought tabu was supposed to do everything tabularx does, but footnotes do not show up in tabu tables.

Working (using tabularx):

\documentclass{article}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{5cm}{c}
Cell \footnote{Footnote}
\end{tabularx}
\end{document}

Not working (with tabu):

\documentclass{article}
\usepackage{tabu}
\begin{document}
\begin{tabu}{c}
Cell \footnote{Footnote}
\end{tabu}
\end{document}
  • 3
    I can confirm this behaviour. Seems to be a bug as far as I understand tabus documentation. The maintainer is Florent Chervet. Does this package have a bug tracker? – Toscho Apr 25 '13 at 14:42
  • 1
    It works if you load hyperref after tabu and don't use tabu inside table as it is a float. – cacamailg Apr 25 '13 at 17:29
  • Or you can use the threeparttable (or threeparttablex), which I found to be the best option. – cacamailg Apr 25 '13 at 17:39
  • 1
    @cacamailg: I thought tabu was supposed to be in table; tabu for example doesn't support \caption. – roelandvanbeek Apr 25 '13 at 19:37
  • Yes I know. Unfortunately it seems there is a bug. You can use \captionof instead of \caption. I will try to provide an example. – cacamailg Apr 25 '13 at 22:41
  • 1
    I could not find any bug tracker, so I emailed the author, but I didn't receive a reply, unfortunately. – roelandvanbeek May 15 '13 at 08:33

2 Answers2

3
\documentclass{article}
\usepackage{tabu}
\usepackage{hyperref}   % this line is added.
\begin{document}
\begin{tabu}{c}
Cell \footnote{Footnote}
\end{tabu}
\end{document}

As @cacamailg said in comment, "It works if you load hyperref after tabu". Thank you, @cacamailg.

ruseel
  • 146
  • 1
    I added hyperref to my document (even if it wasn't used before) but my footnotes still don't show up. Although other footnotes that were already showing up now have a hyperlink as well. – Superbest May 27 '15 at 03:43
  • 1
    It does not work. – pixelou Sep 24 '18 at 13:23
  • check this link for comprehensive list of solutions: https://stackoverflow.com/questions/2888817/footnotes-for-tables-in-latex/2891556#2891556 – Tim Oct 18 '19 at 16:09
1

The code below seem to work:

\documentclass{report}

%Thanks to David Carlisle for pushftn and popftn : http://tex.stackexchange.com/a/43695/7128
\makeatletter
\newtoks\FTN@ftn
\def\pushftn{%
 \let\@footnotetext\FTN@ftntext\let\@xfootnotenext\FTN@xftntext
  \let\@xfootnote\FTN@xfootnote}
\def\popftn{%
 \global\FTN@ftn\expandafter{\expandafter}\the\FTN@ftn}
\long\def\FTN@ftntext#1{%
  \edef\@tempa{\the\FTN@ftn\noexpand\footnotetext
                    [\the\csname c@\@mpfn\endcsname]}%
  \global\FTN@ftn\expandafter{\@tempa{#1}}}%
\long\def\FTN@xftntext[#1]#2{%
  \global\FTN@ftn\expandafter{\the\FTN@ftn\footnotetext[#1]{#2}}}
\def\FTN@xfootnote[#1]{%
   \begingroup
     \csname c@\@mpfn\endcsname #1\relax
     \unrestored@protected@xdef\@thefnmark{\thempfn}%
   \endgroup
   \@footnotemark\FTN@xftntext[#1]}

\makeatother

\usepackage[hyperfootnotes=false]{hyperref}
%\usepackage{hyperref}
\usepackage{varwidth}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{tabu}

\begin{document}

\begin{table}[htbp]
\begin{varwidth}{\textwidth}
\caption{Testing table}
\renewcommand{\footnoterule}{\vspace{-0.5\skip\footins}}
%\renewcommand{\footnoterule}{}
\begingroup\pushftn
\begin{tabu} to \linewidth{lX}
\toprule
a & b\footnote{AB} \\
\midrule
c & d\footnote{CD} \\
\bottomrule
\end{tabu}
\endgroup\popftn
\end{varwidth}
\end{table}

\noindent
Some text 1\footnote{This is a footnote 1.}.
\noindent
Some text 2\footnote{This is a footnote 2.}.

\end{document}
Troy
  • 13,741
cacamailg
  • 8,405