Tables with footnotes for various purposes [closed]

I am searching for a method to keep consistency in the text regarding footnotes. Therefore I tested some options:

• tabu, longtabu, and longtable
• tablefootnotes
• ctable

The first method (tabu, longtabu, and longtable) seems to me the most promising since it can be used for long tables or short tables. But it has the disadvantage of placing only notes in the end of page.

The second method (tablefootnotes) can be used in couple of tabular environments and provides the command \tablefootnote. It also only places the footnotes in the end of page.

The third method (ctable) is currently the one that I am using. It places fake footnotes right after the table. But they are not hyperlinked and do not maintain consistency with the ones in text.

So my question is if anyone knows a method where I can do the following with footnotes in tables:

• Depending on the necessity, place notes right after the table or in the end of page
• Keep consistency with the regular footnotes in the text (therefore the \footnote command is preferable)
• Hyperlinked footnotes are preferable

I already tried many approaches but with no concrete solution.

-
Welcome to TeX.sx! Your question and 'answers' seem to be rather unfocussed and confusing. Unlike a traditional forum, the idea here is to have one issue per question, and keep question and answer material separate. This means that similar questions and answers can be 'collected up' so they only need to be given once. I will return in a little while and delete this question: please re-ask each part separately. –  Joseph Wright Aug 15 '12 at 7:08
Well I do not know the traditional behavior herein. I just wanted a way to create tables (that could spread in several pages or not) with the possibility to add footnotes on them. My last answer is the final answer because it does (almost everything) what I just explained. I know that many people asked about footnotes in tables, but it seemed that my purpose was quite different. –  cacamailg Aug 15 '12 at 17:56
As it stands, this really does not fit our format, so I've closed it as 'Not A Real Question'. As you say, some of the information might be useful to others, but it would be better in a more accessible format. –  Joseph Wright Aug 16 '12 at 16:37

closed as not a real question by Joseph Wright♦Aug 16 '12 at 16:36

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

The following solution works fine. The only thing that I noticed it does not work is with the option para of threeparttable.

\documentclass{scrartcl}

\usepackage{blindtext}

\usepackage{tabu,longtable}
\usepackage{threeparttable} % <-- the package below already loads it
\usepackage[referable]{threeparttablex}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{hyperref}
%\usepackage{caption} % <-- format captions, keep consistency
%     and provides \captionof
\abovetopsep=1ex % <-- controls the space between caption (top) and float

\usepackage{etoolbox}
\makeatletter
\chardef\TPT@@@asteriskcatcode=\catcode*
\catcode*=11
\expandafter\patchcmd\csname\string\threeparttable\endcsname
{\TPT@hookin{tabular}}
{\TPT@hookin{tabular}\TPT@hookin{tabu}}
{}{}
\catcode*=\TPT@@@asteriskcatcode
\makeatother

\begin{document}

\listoftables

\bigskip

\blindtext

\begin{table}[htbp]
\centering
\begin{threeparttable}
\caption{A regular tabular}
\begin{tabu}{lll} % <-- also works with tabular or tabularx or
%   \begin{tabu} to \linewidth {XXX}
\toprule
Column 1 & & Column 2 \\
\midrule
AAAA & & BBBB\tnotex*{tn:cc} \\
CCCC & & DDDD\tnotex{tn:dd} \\
\bottomrule
\end{tabu}
\begin{tablenotes}
\footnotesize
\item[e] \label{tn:cc} Footnote in regular table 1 (not linked).
\item[f] \label{tn:dd} Footnote in regular table 2.
\source Some general note
\end{tablenotes}
\end{threeparttable}
\end{table}

\blindtext\footnote{This is a footnote in the text.}.

\begin{ThreePartTable} % <-- the construction above works with longtable
%     but does not allow page break
\begin{TableNotes}
\footnotesize
\item[a] \label{tn:aa} Footnote in long table 1 (not linked).
\item[b] \label{tn:bb} Footnote in long table 2.
\source Some general note
\end{TableNotes}
\captionof{table}{A long table} % <-- caption inside longtabu within
%     ThreePartTable does not produce
%     correct hyperlink in LOT
\vspace{-\abovecaptionskip} % <-- removes the extra space (correct value?)
\begin{longtabu}{lll} % <-- also works with longtable and
%     \begin{longtabu} to \linewidth {XXX}
%\caption{A long table} \\
\toprule
Column 1 & & Column 2 \\
\midrule
\caption[]{A long table} \\
\toprule
Column 1 & & Column 2 \\
\midrule
\cmidrule{3-3}
\multicolumn{3}{r}{\small\textit{continued}}
\endfoot
\bottomrule
\insertTableNotes\\
\endlastfoot
AAAA\tnotex*{tn:aa} & & BBBB \\
\newpage % <-- just testing break page
CCCC & & DDDD\tnotex{tn:bb} \\
\end{longtabu}
\end{ThreePartTable}

\blindtext

\end{document}


Which gives:

Hope that helps who was searching for the same solution.

-
It also works with para option. The line change occurred because of table was not wide enough. –  cacamailg Aug 13 '12 at 21:24

I have already did some progress on this.

The following MWE almost works the way that I want.

\documentclass{article}

\usepackage{hyperref}
\usepackage{longtable,tabu}
\usepackage{tablefootnote}

\newenvironment{alphafootnotes}
{\par\edef\savedfootnotenumber{\number\value{footnote}}
\renewcommand{\thefootnote}{\alph{footnote}}
\setcounter{footnote}{0}}
{\par\setcounter{footnote}{\savedfootnotenumber}}

\makeatletter
\newcommand{\spewnotes}{%
\tfn@tablefootnoteprintout%
\global\let\tfn@tablefootnoteprintout\relax%
\gdef\tfn@fnt{0}%
}
\makeatother

\begin{document}

\begin{table}
\begin{minipage}{\textwidth}
\begin{alphafootnotes}
\begin{tabu} to \textwidth{lX}
aa & bb\tablefootnote{Footnote within table.} \\
cc & dd
\end{tabu}
\end{alphafootnotes}
\spewnotes
\end{minipage}
\end{table}

This is a footnote\footnote{Here is a footnote within the footnote}.

\newpage

Some text in new page.

\end{document}


There are some problems:

1. If I use tabular the footnotenumber is not printed;
2. If I use tabu (or longtabu) the footnotenumber is not printed and footnotetext is printed twice;
3. If I use tabu to width (or longtabu to width) like in the MWE the footnotenumber is not printed and footnotetext is printed 3 times.

However it seems that apart from the the additional prints of footnotetext the hyperlink is working fine, since it goes to the last print of footnotetext.

Is there a way to make footnotenumber be printed and avoid additional printouts of footnotetext?

-
I feel that this would be more a question than an answer? Rather than answering your own question and posing more questions, you should concentrate on the specifications you are looking for and update your question. –  azetina Aug 12 '12 at 21:20

The following code does work with tabu, tabular, and tabularx either inside table or not. However hyperref must be loaded with hyperfootnotes=false.

\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{footmisc}
\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\footnote{This is a footnote.}.

\end{document}
`
-
This does not work with long tables due to page beaks. –  cacamailg Aug 13 '12 at 2:14