latex2e icon indicating copy to clipboard operation
latex2e copied to clipboard

Longtable: Allow footnotes on head/foot of table

Open adunning opened this issue 6 years ago • 7 comments

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

test.log

adunning avatar Nov 25 '18 20:11 adunning

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.

davidcarlisle avatar Nov 25 '18 20:11 davidcarlisle

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.

adunning avatar Nov 25 '18 20:11 adunning

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.

stale[bot] avatar Nov 28 '19 04:11 stale[bot]

Still an issue.

adunning avatar Nov 28 '19 07:11 adunning

@adunning yes sorry about that. we are trialling github's automated issue bot, which has caused some churn this morning.

davidcarlisle avatar Nov 28 '19 07:11 davidcarlisle

This issue has been automatically marked as stale because it has not had recent activity.

stale[bot] avatar Jan 27 '20 08:01 stale[bot]

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.

davidcarlisle avatar Mar 28 '21 19:03 davidcarlisle