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:
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:
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:
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:
Now not only the numbers in the footnotes at the bottom of the page are wrong, but also the numbers in the table itself.