Graphics, Figures & TablesFootnote indexing problem in multiple minipages

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Mrhnhrm
Posts: 4
Joined: Tue Dec 03, 2019 9:29 am

Footnote indexing problem in multiple minipages

Post by Mrhnhrm »

Hi, and thanks for taking a look.

So, my document has tables and figures, and some of them require footnotes right under them. Here is what I could come up with:

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{perpage} %the perpage package
\MakePerPage{footnote} %the perpage package command
\renewcommand{\thefootnote}{[\alph{footnote}]}
\let\thempfootnote\thefootnote
\begin{document}
\begin{table}[!h]
\caption{Example table}
\begin{minipage}[t]{1\textwidth}
\begin{tabular}{|c|c|}
\hline
tl \footnotemark & tr \\
\hline
bl & br \footnotemark \\
\hline
\end{tabular}
\footnotetext{top left}
\footnotetext{bottom right}
\end{minipage}
\end{table}
\begin{figure}[!h]
\begin{minipage}[t]{1\textwidth}
*placeholder for image*
\caption{Example figure\protect\footnotemark. Lorem ipsum\protect\footnotemark.}
\footnotetext{first sentence}
\footnotetext{second sentence}
\end{minipage}
\end{figure}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
You see, there is a couple of problems:
  • Although the perpage package is used, it doesn't reset the footnote counter between minipages. Whereas I would like a separate footnote counter in each minipage.
  • Although the footnote markers are placed with correctly ordered indices, the actual footnote explanations in the end of the minipage all have the same index (to be specific, the last assigned within the minipage in question, see attachment). If \setcounter{footnote}{0} is used before the \footnotetext statements, then the footnote explanation have empty indices [].
Any suggestions please? Can this be achieved without the threeparttable? Thanks in advance.
Attachments
Screenshot_20211018_225033.png
Screenshot_20211018_225033.png (22.36 KiB) Viewed 5727 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

Footnote indexing problem in multiple minipages

Post by rais »

Mrhnhrm wrote:
  • Although the perpage package is used, it doesn't reset the footnote counter between minipages. Whereas I would like a separate footnote counter in each minipage.
Well, both {minipage}s are on the same page here. Personally, I'd find it rather disorienting to find the same footnotemarks on one and the same page referring to different things. But if you really have to, you could reset the footnote counter between the {figure} and {table} environments in this case.
Mrhnhrm wrote:
  • Although the footnote markers are placed with correctly ordered indices, the actual footnote explanations in the end of the minipage all have the same index (to be specific, the last assigned within the minipage in question, see attachment). If \setcounter{footnote}{0} is used before the \footnotetext statements, then the footnote explanation have empty indices [].
That's because the \footnotemark command increments the footnote counter, whereas the \footnotetext command leaves it unchanged. For a single \footnotemark/\footnotetext pair, the mechanism works as expected. As soon as you have more than one \footnotemark `in a row', you need to subtract n-1 from the footnote counter before the following \footnotetext command, and \stepcounter{footnote} before any consecutive \footnotetext command.

BTW:
Mrhnhrm wrote:

Code: Select all

\caption{Example figure\protect\footnotemark. Lorem ipsum\protect\footnotemark.}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
isn't a good idea---you'll see that when adding the list of figures, where you'll have the same footnote marks, but no fitting footnote texts. Better use \caption's optional argument (same text without the footnote marks). Guess what, with the optional argument in place you no longer need to protect the footnote marks.

Nevertheless, I let my thoughts churn on the problem a bit...

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{perpage} %the perpage package
\MakePerPage{footnote} %the perpage package command
\renewcommand{\thefootnote}{[\alph{footnote}]}
\let\thempfootnote\thefootnote
\makeatletter
\newcommand*\FNXWarning[1]{% derived from \PackageWarning, hence the \@spaces
\GenericWarning{%
(FN experiment)\@spaces\@spaces%\@spaces\@spaces
}{%
Footnote Experiment Warning: #1%
}%
}
\makeatother
\newcounter{markedfootnotes}
\newif\iffnadjneeded
\newcommand*\xfootnotemark{% the `x' means `experimental' here
\iffnadjneeded
% before the first *text was called
\else
% this is the first *mark (or previous *marks have seen at least one *text)
\ifnum\value{markedfootnotes}>0
\FNXWarning{\themarkedfootnotes\space missing text detected.\MessageBreak
Maybe \string\footnotetext\space instead of \string\xfootnotetext\space was used?\MessageBreak
Expect weird numbering of footnotes}%
\fi
\global\fnadjneededtrue
\fi
\stepcounter{markedfootnotes}%
\footnotemark
}
\newcommand*\xfootnotetext{% the text argument will be picked up by \footnotetext later
\ifnum\value{markedfootnotes}<1
\FNXWarning{Footnotetext without preceding mark detected}%
\else
\iffnadjneeded
\addtocounter{footnote}{-\value{markedfootnotes}}%
\global\fnadjneededfalse
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
If I coded this right, you should see a warning in the log file, if the number of \xfootnotetext commands doesn't match the number of the preceeding \xfootnotemark commands.
Just don't mix \xfootnotemark/\xfootnotetext with \footnotemark/\footnotetext here.

KR
Rainer
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Footnote indexing problem in multiple minipages

Post by Ijon Tichy »

One of the problems is the

Code: Select all

\let\thempfootnote\thefootnote
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Footnotes inside minipages use another counter mpfootnote. But here you are using the footnote counter for the output. If you'd change this, things would become much easier:

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{perpage} %the perpage package
\MakePerPage{footnote} %the perpage package command
\renewcommand{\thefootnote}{[\alph{footnote}]}
\renewcommand{\thempfootnote}{[\alph{mpfootnote}]}
\begin{document}
\begin{table}[!h]
\caption{Example table}
\begin{minipage}[t]{1\textwidth}
\begin{tabular}{|c|c|}
\hline
tl \footnote{top left} & tr \\
\hline
bl & br \footnote{bottom right} \\
\hline
\end{tabular}
\end{minipage}
\end{table}
\begin{figure}[!h]
\begin{minipage}[t]{1\textwidth}
*placeholder for image*
\caption{Example figure\protect\footnote{first sentence}. Lorem ipsum\protect\footnote{second sentence}.}
\end{minipage}
\end{figure}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
And indeed, if you don't want the footnote marks in the list of tables resp. list of figures you should use the optional argument of \caption:

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{perpage} %the perpage package
\MakePerPage{footnote} %the perpage package command
\renewcommand{\thefootnote}{[\alph{footnote}]}
\renewcommand{\thempfootnote}{[\alph{mpfootnote}]}
\begin{document}
\listoftables
\listoffigures
\begin{table}[!h]
\caption{Example table}
\begin{minipage}[t]{1\textwidth}
\begin{tabular}{|c|c|}
\hline
tl \footnote{top left} & tr \\
\hline
bl & br \footnote{bottom right} \\
\hline
\end{tabular}
\end{minipage}
\end{table}
\begin{figure}[!h]
\begin{minipage}[t]{1\textwidth}
*placeholder for image*
\caption[Example figure. Lorem ipsum.]{Example figure\footnote{first sentence}. Lorem ipsum\footnote{second sentence}.}
\end{minipage}
\end{figure}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
or deactivate \footnote inside the auxiliary files of both:

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{perpage} %the perpage package
\MakePerPage{footnote} %the perpage package command
\addtocontents{lof}{\string\renewcommand\string\footnote[2][]{}}
\addtocontents{lot}{\string\renewcommand\string\footnote[2][]{}}
\renewcommand{\thefootnote}{[\alph{footnote}]}
\renewcommand{\thempfootnote}{[\alph{mpfootnote}]}
\begin{document}
\listoffigures
\listoftables
\begin{table}[!h]
\caption{Example table}
\begin{minipage}[t]{1\textwidth}
\begin{tabular}{|c|c|}
\hline
tl \footnote{top left} & tr \\
\hline
bl & br \footnote{bottom right} \\
\hline
\end{tabular}
\end{minipage}
\end{table}
\begin{figure}[!h]
\begin{minipage}[t]{1\textwidth}
*placeholder for image*
\caption{Example figure\protect\footnote{first sentence}. Lorem ipsum\protect\footnote{second sentence}.}
\end{minipage}
\end{figure}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
BTW: For tables another alternative could be usage of threeparttable.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Post Reply