3

My question is different form the question Footnote in tabular environment because I already know how to set footnotes in tabular environments. But I don't know how to correctly use two ore more footnotes that appear together in one table. The other question is not dealing with this special issue.


I have this latex document:

\documentclass{scrbook}
\usepackage{scrlayer-scrpage}
\begin{document}
Text before the table\footnote{This is the 1st footnote}

\begin{tabular}{cl}
$k_B$ & Boltzmann constant\footnotemark $k_B = 1,380649 \cdot 10^{23} J/K$\\ 
$f$ & degrees of freedom\footnotemark \\ 
\end{tabular}
\footnotetext{named after Boltzmann}
\footnotetext{Another word for possibilities}

Text after the table\footnote{This is the last footnote}
\end{document}

I get this body, which is ok:

Body with correct numbers for footnotes

There are four points with footnotes, each of them has its own distinct number, as it should be. Everything is fine here.

But I get these footnotes:

Footnotes with one number wrong

As you can see, the second footnote (which is the first of two inside the table) has a wrong number. The numbers should be 1-2-3-4, but they are 1-3-3-4.

How can I get the correct numbers?


=== Reaction to an answer ===

Fran posted an answer but his solution is just a weak workaround that doesn't work properly in bigger documents with dozens of footnotes.

Suppose you are writing a book, and the table with the two footnotes is on page 580. You create the footnotes like in Fran's workaround, and 3 month later you add another text with another footnote on page 215. I want that all footnotes are correct even after adding or removing preceding footnotes.

An Example:

\documentclass{scrbook}
\usepackage{scrlayer-scrpage}
\usepackage{lipsum}
\begin{document}
\chapter*{Issue with footnotes in tables}
\lipsum[1]

% ===========================================================
% Toggle the next line
% Subsequently added text with a new footnote \footnote{additional footnote}
% ===========================================================

\lipsum[66]

Old text with a footnote\footnote{an old footnote} before the table.

\section*{Table}

\begin{tabular}{cl}
$k_B$ & Boltzmann constant\footnotemark[2]\  $k_B = 1,380649 \cdot 10^{23} J/K$\\ 
$f$ & degrees of freedom\footnotemark[3] \\ 
\end{tabular}

\addtocounter{footnote}{2}
\footnotetext[2]{named after Boltzmann}
\footnotetext[3]{Another word for possibilities}

Text immediately after the table\footnote{immediately after the table}

\lipsum[75]

Text with a footnote\footnote{This is the last footnote}
\end{document}

This code produces this output:

correct output

But then I add some Text with another footnote before the table:

% ===========================================================
% Toggle the next line
Subsequently added text with a new footnote \footnote{additional footnote}
% ===========================================================

and I get this:

output with errors

Now not only the numbers in the footnotes at the bottom of the page are wrong, but also the numbers in the table itself.

2
  • 1
    Footnote in tabular environment might also be interesting.
    – leandriis
    Commented Mar 11, 2019 at 20:00
  • Why did you mark this question as a duplicate? I clearly explained why it is different. Didn't you read the first paragraph of my question? Commented Mar 14, 2019 at 6:46

2 Answers 2

6
\documentclass{scrbook}
\usepackage{scrlayer-scrpage}
\begin{document}
Text before the table\footnote{This is the 1st footnote}

\begin{tabular}{cl}
$k_B$ & Boltzmann constant\footnotemark[2]\  $k_B = 1,380649 \cdot 10^{23} J/K$\\ 
$f$ & degrees of freedom\footnotemark[3] \\ 
\end{tabular}

\addtocounter{footnote}{2}
\footnotetext[2]{named after Boltzmann}
\footnotetext[3]{Another word for possibilities}

Text after the table\footnote{This is the last footnote}

\end{document}

Edit

Some type of automatic adjust as requested is possible making a new environment for the table notes when (1) you do not use this in floats, and (2) of course, the number of \tablefootnotemarks is the same of \tablefootnotexts for each table:

mwe

\documentclass[a6paper,twocolumn]{scrbook}
\usepackage{scrlayer-scrpage}
\usepackage{lipsum,calc,booktabs,parskip}
\newcounter{tablefootnote}
\newcommand\tablefootnotemark{\footnotemark\addtocounter{tablefootnote}{1}} %
\newenvironment{foo}%
{\edef\ntnotes{\thetablefootnote}\setcounter{footnote}%
{\value{footnote}-\value{tablefootnote}}}%
{\edef\ntnotes{\thefootnote}\setcounter{tablefootnote}{0}}
\newcommand\tablefootnotext[1]{\addtocounter{footnote}{1}   \footnotetext{\texttt{[table]} #1}}

\begin{document}
\raggedright
Bla \footnote{footnote 1} bla \footnote{footnote 2} Bla, \footnote{footnote 3} before the table.

\begin{tabular}{cl}\toprule
$foo$ & bah\tablefootnotemark \\ 
$foo$ & bah\tablefootnotemark \\ 
$foo$ & bah\tablefootnotemark \\ 
$foo$ & bah\tablefootnotemark \\\bottomrule
\end{tabular}
\begin{foo}
\tablefootnotext{footnote 4}
\tablefootnotext{footnote 5}
\tablefootnotext{footnote 6}
\tablefootnotext{footnote 7}
\end{foo}

Bla \footnote{footnote 8} bla \footnote{footnote 9} Bla, \footnote{footnote 10} after the table.

\begin{tabular}{cl}\toprule
$foo$ & bah\tablefootnotemark \\ 
$foo$ & bah\tablefootnotemark \\ 
$foo$ & bah\tablefootnotemark \\\bottomrule
\end{tabular}
\begin{foo}
\tablefootnotext{footnote 11}
\tablefootnotext{footnote 12}
\tablefootnotext{footnote 13}
\end{foo}

Bla \footnote{footnote 14} bla \footnote{footnote 15} Bla, \footnote{footnote 16} after the second table.

\begin{tabular}{cl}\toprule
$foo$ & bah\tablefootnotemark \\ 
$foo$ & bah\tablefootnotemark \\\bottomrule
\end{tabular}
\begin{foo}
\tablefootnotext{footnote 17}
\tablefootnotext{footnote 18}
\end{foo}

Bla \footnote{footnote 19} bla \footnote{footnote 20} Bla, \footnote{footnote 21} after the third table.

\end{document}
0
1

Footnotes work normally with longtable. See Footnotes in tables:

\documentclass{scrbook}
\usepackage{longtable}
\begin{document}
Text before the table\footnote{This is the 1st footnote}

\begin{longtable}{cl}
$k_B$ & Boltzmann constant\footnote{named after Boltzmann} $k_B = 1,380649 \cdot 10^{23} J/K$\\ 
$f$ & degrees of freedom\footnote{Another word for possibilities} \\ 
\end{longtable}

Text after the table\footnote{This is the last footnote}
\end{document}

Alternatively, if you want to stick with the tabular environment, add the footnotehyper package:

\documentclass{scrbook}
\usepackage{footnotehyper}
\begin{document}
Text before the table\footnote{This is the 1st footnote}

\begin{tabular}{cl}
$k_B$ & Boltzmann constant\footnote{named after Boltzmann} $k_B = 1,380649 \cdot 10^{23} J/K$\\ 
$f$ & degrees of freedom\footnote{Another word for possibilities} \\ 
\end{tabular}

Text after the table\footnote{This is the last footnote}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .