Graphics, Figures & TablesPossible package/environment for tables with footnotes in them

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Possible package/environment for tables with footnotes in them

Post by kaiserkarl13 »

I tinkered around the last day or so to write a (short) package to make an environment that does "automatic" tables with footnotes under them. Some people call these "table notes." It basically stores the width of the table in the .aux file, then on the next run updates the width of the enclosing minipage to "hug" the table.

The primary purpose for this is to get the footnotes to have proper margins. For example,

Code: Select all

\begin{minipage}{\linewidth}
  \begin{tabular}{l l}
  \hline
  Hello & world!\footnote{This is a long footnote that will overhang the table} \\
  Hello & again! \\
  \hline
  \end{tabular}
\end{minipage}
will produce a footnote that goes well beyond the boundary of the table. Alternatively, one could add \centering inside the minipage, which would mean the footnote underruns both sides of the table. The only way I know of to do this "naturally" (i.e., with \footnote and without using packages like threeparttable that require a bit more manual control of things) is to manually set the width to the width of the table (which of course requires tweaking when the table's content changes).

With the new environment, the footnotes are always exactly the same as the width of the table itself (at least, they are after the second and subsequent runs). One can then apply centering (etc.) to the table, including footnotes, as a whole, which is typically what is desired. The result using the example above with this new environment (which I call "mptabular" for obvious reasons) produces the equivalent of

Code: Select all

\begin{minipage}{78.19461pt}
  \begin{tabular}{l l}
  \hline
  Hello & world!\footnote{This is a long footnote that will overhang the table} \\
  Hello & again! \\
  \hline
  \end{tabular}
\end{minipage}
Except that the user does not have to explicitly enter (or know) the width of the minipage.

The question I have is this: would this package be of interest to the community? If so, is it a duplication of something already out there, or does this functionality not yet exist?

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Post Reply