Archive

Posts Tagged ‘table’

LaTeX: adding footnotes in tables (or other floats)

June 15th, 2009

I recently wanted to put a footnote reference inside a table. Unfortunately, LaTeX makes it somewhat difficult to add footnotes inside floats (e.g., tabular). If you try to put a footnote inside a tabular, then pdflatex will show the reference but not the footnote itself! I came across several suggestions for fixing this:

One idea is to put the table in a minipage. This causes the footnote to show up at the bottom of the table (in its own numbering system) — but I wanted the footnote to show up at the bottom of the page like other footnotes!

Another idea was to manually specify the footnote number inside the text and then use the \footnotetext command (outside the tabular) to manually add the footer. Unfortunately, this is not a robust solution since it forces you to manually maintain this footnote number inside the tabular.

Building on the previous idea, I discovered a way to make footnotes appear inside tabulars without breaking the automatic numbering of footnotes. Here is my approach:

  1. Include the “fmtcount” package so that you can display the values of counters (e.g., the footnote counter):
    \usepackage{fmtcount}
  2. Immediately before your tabular, increment the footnote counter:
    \addtocounter{footnote}{1}
  3. Next, specify the contents of the footnote:
    \footnotetext[\value{footnote}]{your text here}
  4. Finally, add a reference to the footnote inside the table:
    $^{\decimal{footnote}}$

You can extend this idea to add multiple footnotes within a single tabular by adjusting the counters (using \addtocounter) appropriately. Here is a complete example of how to add two footnotes inside a single tabular (you can see the PDF output here):

\documentclass[12pt]{article}
 
\usepackage{fmtcount} % displaying latex counters
 
\begin{document}
    \title{An Example of Footnotes Inside a Tabular}
    \author{David Gridley Underhill}
    \maketitle
 
% manually add a footnote which exists inside the table
\addtocounter{footnote}{1}
\footnotetext[\value{footnote}]{my first footnote}
 
% add another footnote
\addtocounter{footnote}{1}
\footnotetext[\value{footnote}]{my second footnote}
 
% reset the counter to the first footnote's value
\addtocounter{footnote}{-1}
 
\begin{tabular}{|l|l|}
  \hline
  % this next row references the first footnote I added above, and then
  % advances the counter to the next footnote.
  {\bf First Column} & {\bf Second Column}$^{\decimal{footnote}}$\addtocounter{footnote}{1} \\
 
  \hline
  % now reference the second footnote from above -- don't increment the footnote 
  % counter beyond the last footnote!
  X & Y$^{\decimal{footnote}}$ \\
 
  \hline
\end{tabular}
 
\end{document}

David Underhill Coding, LaTeX , , , , , ,