I have a hard time with footnotes...
I use the package tablefootnotes with a defined command \spewnotes to display multiple footnotes in a theorem, following another post on this forum.
However, sometimes a footnote placed inside a figure capture sometimes would skip a number
and the footnote text would appear twice, as you can see below with footnote 4 (or 3).
Can anybody explain to me why this is the case? Does it depend on the order of the imports, and if so, why? Thank you for helping me!
Minimal working example
Expected behaviour
Footnote 4 (rsp. 3) shouldn't be duplicated. Footnote 5 is displayed like I expect it.
Observations
- Error goes away if I don't import
hyperref - Error goes away if caption has less than 55 characters
- Number of characters depends on imports (was at 60 in my full document)
Output
Code
\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{tablefootnote}
\usepackage{float}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz} % has to go after xcolor
\usepackage{thmtools}
\definecolor{colorLink}{RGB}{61, 145, 60}
\declaretheorem[numberwithin=chapter, thmbox=M]{theorem}
% tablefootnotes & \spewnotes are used for multiple footnotes within a theorem.
\makeatletter
\newcommand{\spewnotes}{%
\tfn@tablefootnoteprintout%
\global\let\tfn@tablefootnoteprintout\relax%
\gdef\tfn@fnt{0}%
}
\makeatother
\usepackage{hyperref}
\hypersetup{hidelinks,colorlinks,linkcolor=colorLink}
\begin{document}
\chapter{Title}
\begin{theorem}
A theorem with\tablefootnote{A} two footnotes\tablefootnote{B}.
\end{theorem}
\spewnotes
\begin{figure}[H]
\centering
\begin{tikzpicture}
\draw[fill=gray!20] (0,0) ellipse (.2 and .1);
\end{tikzpicture}
\caption[Fig1]{
1aaa 1bbb 2aaa 2bbb 3aaa 3bbb
4aaa 4bbb 5aaa 5bbb 6aaa 6\tablefootnote{Why does this appear twice?}.}
\end{figure}
\spewnotes
\begin{figure}[H]
\centering
\begin{tikzpicture}
\draw[fill=gray!20] (0,0) ellipse (.2 and .1);
\end{tikzpicture}
\caption[Fig]{
1aaa 1bbb 2aaa 2bbb 3aaa 3bbb
4aaa 4bbb 5aaa 5bbb 6aaa \tablefootnote{It appears only once
if the caption is short enough, $<56$ in this example
(or $<61$ if I include my uni's .sty file)}.}
\end{figure}
\spewnotes
\end{document}
