# handyfloss

## LaTeX: footnotes in tables

Posted by isilanes on September 5, 2006

Blog moved to: handyfloss.net

Entry available at: http://handyfloss.net/2006.09/latex-footnotes-in-tables/

Although an apparently widely known LaTeX issue, I came across it just today. Fact is if you use \footnote inside a \tabular environment, the footnote will be “trapped” inside the table, and actually never get displayed at all in the output.

You can find some possible solutions for that at the UK TeX FAQ on the Web.

The trick I’ll comment here is to use \tabularx, which is covered in the link above, and also at J.L. Diaz’s LaTeX blog[es].

The “problem” is that \tabularx requires a fixed table width value to be input by the user, so the following will fail misserably:

 \usepackage{tabularx} % required in the preamble \begin{tabularx}{100mm}{|c|c|} \hline A & B \\ \hline C & D \\ \hline \end{tabularx} 

Why? Because the {c} especification (to center the text inside the cell) makes the affected column as wide as necessary, not more (so will {r} or {l}). The output can be seen below:

The effect of the whole table being actually wider than the sum of the integrating colums could be partially “concealed” if the \hlines were eliminated, but the table would still be actually incorrectly wide, which would make things like aligning the whole table “fail” (to the eye).

Fortunately, the tabularx package provides a way to tell LaTeX that a column must be of the necessary width, so that the sum of colum widths equals the total column width. This is the {X} keyword (notice the capitalization of the “X”). E.g.:

 \begin{tabularx}{100mm}{|c|X|} \hline A & B \\ \hline C & D \\ \hline \end{tabularx} 

This makes the first column just as wide as needed, not more (the {c}), and then, the second column will be as wide as needed to reach the 100mm. The output:

If multiple columns are given the {X} keyword, they will all have the same width, precisely the one required to meet the total table width.