latex2e
latex2e copied to clipboard
Longtable: Allow footnotes on head/foot of table
Brief outline of the bug
As noted in the longtable
documentation:
Note however that
\footnote
will not work in the ‘head’ or ‘foot’ sections of the table. In order to put a footnote in those sections (e.g., inside a caption), use\footnotemark
at that point, and\footnotetext
anywhere in the table body that will fall on the same page.
This is difficult to accomplish if one is generating LaTeX using another program. A more manageable solution is to use the footnote
package. Unfortunately, this package hasn't been updated since 1997 and is rather delicate (e.g. it fails if xcolor
is loaded afterwards). It would be brilliant if the relevant code could be included in longtable
itself to remove the need for footnote
.
Minimal example showing the bug
\RequirePackage{latexbug}
\documentclass{article}
\usepackage{longtable}
% footnote silently disappears without the following line
\usepackage{footnote}\makesavenoteenv{longtable}
\begin{document}
\begin{longtable}[]{@{}lr@{}}
& foo\footnote{Foo bar baz.}\tabularnewline
\endhead
X & 23,39\tabularnewline
Y & 29,33\tabularnewline
\end{longtable}
\end{document}
Log file (required) and possibly PDF file
Thank you for your reprt.
The real problem is that longtable head and foot are only typeset once, in a box. There are some pros and cons to that design, but it is deeply embedded in the longtable code and not easily changed without major re-writes.
The footnote package workaround is equivalent to the "standard" workaround for footnotes on a box, using \footnotemark
in the box and \footnotetext
at some point on the main page. But for longtable it suffers from the same problem, every page has a superscript 1 in the header but there is just a single footnote, which is on the last page of the table.
There is a start of a longtable version 5 with some experimental code to avoid boxing the table head at
https://github.com/davidcarlisle/dpctex/tree/master/longtable
However that version of the package is not stable enough for general use yet, sorry.
Thank you for the explanation! No rush from my perspective; I only wanted to make sure it was documented, since use of the footnote
package is recommended in many places but rarely noting the problems it brings.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Still an issue.
@adunning yes sorry about that. we are trialling github's automated issue bot, which has caused some churn this morning.
This issue has been automatically marked as stale because it has not had recent activity.
I am going to re-classify this as long term, there really isn't a good fix while the table head is a static box and as noted above that is deeply ingrained in the current design.