129

I thought that footnotes would have only a problem with the table environment, but none of the answers in

seem to work for the tabular environment.

\documentclass{scrartcl}

\begin{document} \begin{tabular}{l} Content\footnote{Footnote} \end{tabular} \end{document}

inavda
  • 136
  • 1
  • 7
strpeter
  • 5,215
  • 12
    what about the classic \footnotemark/\footnotetext approach? – cgnieder Apr 18 '13 at 18:45
  • Another simple way to use \footnote is to wrap \begin{tabular} in a minipage. Just surround it with \begin{minipage}{\linewidth} ... \end{minipage}. The footnote numbers will be the letters a, b, ... – Jasper Nov 09 '20 at 14:37

10 Answers10

98

For some reason (my preferred choice) the tablefootnote package only works if you wrap the tabular in a table float. A way around is to use \footnotemark and \footnotetext:

\documentclass{scrartcl}

\begin{document}
before

\begin{tabular}{l} Content\footnotemark\ Content continued\footnotemark\ Content continued further\footnotemark \end{tabular} \footnotetext[1]{Footnote} \footnotetext[2]{Second footnote} \footnotetext{Third footnote}

after \end{document}

Note how manual numbering of all but the first footnotetext is necessary. In a longer document, an approach with manually decrementing and incrementing the footnote number might be more viable; that way, the only way you have to watch out for is decrementing by the correct number:

\documentclass{scrartcl}
\begin{document}    
before

\begin{tabular}{l} Content\footnotemark\ Content continued\footnotemark\ Content continued further\footnotemark \end{tabular} \addtocounter{footnote}{-2} \footnotetext{Footnote} \addtocounter{footnote}{1} \footnotetext{Second footnote} \addtocounter{footnote}{1} \footnotetext{Third footnote}

after \end{document}

sample output

user202729
  • 7,143
Count Zero
  • 17,424
  • 5
    I need to upvote this! Exactly what I commented, too ;) – cgnieder Apr 18 '13 at 18:55
  • @cgnieder: Thanks for appreciating my originality. :D I was typing up the answer when you posted your comment. – Count Zero Apr 18 '13 at 18:59
  • @CountZero: This works great even with surrounding table environment! Thanks. But I understand that most people do not prefer it this way around. – strpeter Apr 19 '13 at 08:48
  • 3
    Didn't work for me, \footnotetext content was not rendered at all – Hennadii Madan Oct 12 '16 at 12:59
  • FYI separating \footnotemark and \footnotetext risks placing of the footnote content on a different page in some cases. – jessexknight May 18 '18 at 15:12
  • 6
    Placing multiple \footnotemark in the same table required manual numbering in the \footnotetext[number]{text} command in my case. – Hodossy Szabolcs May 25 '18 at 06:40
  • 5
    @HennadiiMadan: One has to put the \footnotetext outside the table environment. – strpeter Jul 03 '18 at 09:19
  • @HodossySzabolcs I wonder if there is a way around the manual numbering. Manual numbering goes against one of the strong points of using LaTeX – HackerBoss Mar 21 '20 at 21:52
  • @HackerBoss See the edited answer. You still have to adjust the first \addtocount{footnote}{-X} so that X=number of footnotes in the table - 1 whenever you change the number of footnotes inside the table; in case of extra large tables with dozens of footnotes, you could store the current value of the footnote counter before the table and then reset it to that value before the first footnotetext command. – Ansa211 May 14 '20 at 07:24
87

another possibility is with the footnote package and \makesavenoteenv{tabular}:

\documentclass{scrartcl}
\usepackage{footnote}
\makesavenoteenv{tabular}
\begin{document}
\begin{tabular}{l}
Content\footnote{footnote text}
\end{tabular}
\end{document}

If one has both tabular-only environment and tabular inside table, it is possibile to load both \makesavenoteenv{tabular} and \makesavenoteenv{table} in the preamble, like this:

\documentclass{scrartcl}
\usepackage{footnote}
\makesavenoteenv{tabular}
\makesavenoteenv{table}
\begin{document}
\begin{table}
\begin{tabular}{l}
Content\footnote{footnote text}
\end{tabular}
\end{table}
\begin{tabular}{l}
Content\footnote{footnote text}
\end{tabular}
\end{document}

So to have a more general solution.

Also, a fairly comprehensive list of solutions can be found inside the documentation for the tablefootnotepackage, starting from page 3, section "Alternatives".

d-cmst
  • 23,095
  • 1
    But this unfortunately works only if one has no table environment around it. – strpeter Apr 19 '13 at 08:43
  • 1
    ah! I thought the question was exactly to provide a solution for the case when there is only a tabular environment, not inside a table, as per your MWE. If your tabular is inside a table you can use the tablefootnote package, as per your first link – d-cmst Apr 19 '13 at 08:49
  • Your first answer is completely right, but I am always interested in answers that can be generalized. – strpeter Apr 19 '13 at 08:52
  • I see it now... if you want a unified approach with the footnote package, just load both \makesavenoteenv{tabular} and \makesavenoteenv{table} and you're all set :) – d-cmst Apr 19 '13 at 08:59
  • This would be perfect with some little explanation of what's going on under the hood, I mean, what those commands are doing. – jasikevicius23 Jun 03 '14 at 17:37
  • 2
    @jasikevicius23, I'd leave that to the footnote package documentation. However please feel free to edit the answer if you think it can be improved in any way. – d-cmst Jun 03 '14 at 19:01
  • Note that (as mentioned in the linked documentation) hyperlinks from the footnote mark to the text do not work properly for this solution. – Marijn Jun 14 '18 at 10:52
  • 1
    @Marijn The footnotehyper package has superseded the original footnote, fixing the hyperlinks problem. – Andrew Dunning Jan 20 '19 at 02:24
24

You can also use threeparttable package to insert footnotes in the tables.

\documentclass{article}
\usepackage[flushleft]{threeparttable}
\begin{document}
\begin{table}[h]
\caption{Example of test session results}
\label{tab:test_results}
\centering
\begin{threeparttable}
  \begin{tabular}{|l|l|l|}
    \hline
    Mutants & CPU\tnote{1}     & Memory\tnote{2}    \\ \hline
    Mutant-1   & 23 & 15 \\ \hline
    Mutant-2   & 32 & 11 \\ \hline
  \end{tabular}
  \begin{tablenotes}
    \item[1] Measured in percentages.
    \item[2] Measured in kilobytes (KB).
  \end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}

Output:

Table

arman
  • 411
  • Do I understand correctly that this will change the layout of the rest of the table? – Marten Apr 16 '21 at 15:48
  • I don't think so. I have updated the answer to show how the table would look like. – arman Apr 19 '21 at 16:14
  • 1
    This was a lifesaver. The other answers did not work for me, and threeparttable looks fantastic. It's simple to write and keeps the notes with the table. – Nate Apr 11 '23 at 21:19
7

I insert footnotes manually at the bottom of the table, which is pretty simple and requires no additional package:

\begin{table}
\caption{The Table.}
\centering
  \begin{tabular}{lrr}
   \hline
          & Variable A & Variable B \\
   \hline
      Item 1        & 234.5 & 678.9 \\
      Item 2~$^{1}$ & 432.1 & 876.5 \\
   \hline
   \multicolumn{3}{l}{$^{1}$\footnotesize{Here is a footnote.}} \\
  \end{tabular}
\end{table}
Luís de Sousa
  • 398
  • 5
  • 21
  • Note that \footnotesize takes no argument, and changes the size of all the text following it (until the end of the group). So the {...} after \footnotesize is misleading. – user202729 Jan 27 '24 at 22:03
3

If you use bidiftnxtra (a part of bidi package), all combinations of table and tabular will work. Ofcourse, this only work if you are using xelatex but the approach can be ported to other packages too:

\documentclass{scrartcl}
\usepackage{bidi}
\usepackage{bidiftnxtra}
\begin{document}
\begin{tabular}{l}
Content\footnote{Footnote}
\end{tabular}

\begin{table}[h]
\centering
\begin{tabular}{l}
Content\footnote{Footnote}
\end{tabular}
\caption{This is a caption\footnote{Another footnote.}}
\end{table}
\end{document}
2

I particularly like @CountZero's answer, yet it may happen that your footnote mark is on a different page than your footnote text. In that case, you can move around the \footnotetext to solve that, but how do you become aware of it in the first place?

This code will issue a warning when that happens:

\documentclass{article}

% works with hyperref, too:
% \usepackage{hyperref}

% Footnotes in table with page-number check
\usepackage{refcount}
\newcommand{\myfootnotemark}{\footnotemark\label{fn:mark}}
\newcommand{\myfootnotetext}[1]{\footnotetext{#1\label{fn:text}%
        \edef\fnmark{\getpagerefnumber{fn:mark}}%
        \edef\fntext{\getpagerefnumber{fn:text}}%
        \ifx\fnmark\fntext\else\ClassWarning{}{footnote mark and text on different pages!}\fi}}

\begin{document}
    \begin{tabular}{l}
%       Table stuff \footnote{This does not work: the footnote is missing.}
        Table stuff \myfootnotemark
    \end{tabular}

% uncomment to see the warning:
% \pagebreak

\myfootnotetext{So we do this instead!}

\end{document}

It works only for a single \footnotemark/\footnotetext pair so far, but extension should not be too difficult and those who use this weird hack more than once in a document are hopefully apt enough to adapt my code accordingly :)

bers
  • 5,404
1

An alternative solution with talltblr environment of tabularray package:

\documentclass{article}

\usepackage{hyperref} \hypersetup{colorlinks}

\usepackage{tabularray}

\begin{document}

\begin{table}[!htbp] \centering \begin{talltblr}[ caption = {Long Long Long Long Tabular}, note{a} = {It is the first footnote.}, note{b} = {It is the second long long long long long long footnote.}, ]{ colspec = {XXX}, width = 0.8\linewidth, hlines, } Alpha & Beta & Gamma\TblrNote{a} \ Epsilon & Zeta & Eta \ Iota & Kapp & Lambdaa\TblrNote{b} \ \end{talltblr} \end{table}

\end{document}

enter image description here

L.J.R.
  • 10,932
1

The package nicematrix provides an environment {NiceTabular} which is similar to the classical {tabular} (of array) but this extra features.

  • When the package is loaded with the key footnote or the key footnotehyper, the commands \footnote are extracted from the tabular (by using the corresponding package: footnote or footnotehyper).

  • There is a command \tabularnote from notes which are composed under the tabular.

Demonstrating example:

\documentclass{article}
\usepackage{geometry}
\geometry{height=10cm} % in order to have a smaller output (for this post)

\usepackage{booktabs,enumitem} \usepackage[footnotehyper]{nicematrix} \usepackage{hyperref}

\begin{document}

\begin{NiceTabular}{l} \toprule Content in the first row\tabularnote{A tabular note} \ Some content in the second row\footnote{A footnote} \ \bottomrule \end{NiceTabular}

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

strpeter
  • 5,215
F. Pantigny
  • 40,250
1

Use the footnotehyper package.

Usage

Just insert

\usepackage{footnotehyper}
\makesavenoteenv{table}
\makesavenoteenv{tabular}

in the preamble.

Example

\documentclass{article}
\usepackage{hyperref}
\usepackage{footnotehyper}
\makesavenoteenv{table}
\makesavenoteenv{tabular}
\begin{document}

\begin{table}[p] \centering \begin{tabular}{|c|c|} \hline Item 1 & Item 2\footnote{Footnote of the floating table on the other page.} \ \hline Item 3\footnote{Another footnote of the floating table on the other page.} & Item 4 \ \hline \end{tabular} \caption{Table with Hyperref Support and Multiple Footnotes} \end{table}

\begin{center} \begin{tabular}{|c|c|} \hline Item 5\footnote{Footnote in tabular environment.} & Item 6\footnote{Footnote in tabular environment.} \ \hline \end{tabular} \end{center}

\end{document}

Limitation

As mentioned in the package documentation, even though the footnotes will show up for floating environments, they may be not on the correct page. For tabular environment, it works fine.

documentation

Comparison

This is an extensive comparison of all the solutions listed.

Features to be tested:

  1. hyperref support
  2. footnotetext are placed on the correct page where the footnotemark appear for floating table
  3. automatic numbering when there are multiple footnotes
  4. footnotes are placed below the table/at the bottom of the page
  5. support for tabular environment itself without table environment around it
  6. support for floating environment, tabular inside table
Package 1 2 3 4 5 6
footnotehyper yes no yes bottom of the page yes yes
footnote one link per table no yes bottom of the page yes yes
tablefootnote yes no yes bottom of the page no yes
longtable only go to last page no yes bottom of the page yes yes
ftnxtra no no yes bottom of the page yes no
threeparttable no yes yes below the table yes yes
tabularx no no yes bottom of the page yes no
bidiftnxtra no no yes bottom of the page yes no
nicematrix yes no yes both supported yes no
tabularray yes yes no below the table yes yes
raw footnotemark/footnotetext one link per table no yes bottom of the page yes no

The source code for the comparison, as well as links to original answer suggesting the package, can be found at https://gist.github.com/user202729/09825890622de02512e750e04eee41d4 .

Things missing here

Things that could be tested, but isn't:

Features that could be tested, but isn't:

  1. support for align environment from amsmath
user202729
  • 7,143
0

As also posted here, you can also use define a footnote outside the table/tabular by using a custom command marklessfootnote, and then refer to it within the table instead.

\newcommand\marklessfootnote[1]{
    \addtocounter{footnote}{1}
    \footnotetext{#1}
}

The marklessfootnote can then be referred to within a table using a regular \ref command, or the cleveref package command \cref with ease, also compatible with hyperref package.

Ref:

%... inside my doc
\marklessfootnote{My footnote \label{ftn:01}}
%... inside my tabular...
\textsuperscript{\tiny\ref{ftn:01}} % With commands to superscript the mark.

Cleveref:

Note to make Cref link the same style as the regular footnote, you can redefine the format as follows.

\crefformat{footnote}{#2\textsuperscript{\footnotemark[#1]}#3} %option to superscript mark.
%... %inside my doc
\marklessfootnote{My footnote \label{ftn:01}}
%... %inside my tabular...
\cref{ftn:01}
Mr G
  • 1,359