Using footnote in tables

Have you ever tried to add a footnote to a table inside the tabular environment? Even though the index is printed, the search for the actual footnote will be in vain.

One way to overcome this issue is by using longtable. The package handles footnotes really well. But it may be an overkill if your table is small.
Also, I read the tabularx package also handles footnotes correctly, I haven’t tested it though.

Another, more appropriate solution would be using the minipage environment. Here is an example:

\begin{minipage}{6cm}
	\begin{tabular}{|l|c|c|}
		\hline
		A & 1 & 2 \footnote{This is a footnote.} \\
		\hline
		B & 2 & 1 \\
		\hline
		C & 3 & 3 \\
		\hline
	\end{tabular}
\end{minipage}

Minipage table footnote example

Minipage table footnote example.

Obviously, the footnote is placed right below the table, which may or may not be what you want. In addition, since minipage is not a floating environment, adding a caption inside the minipage environment gives the following error message: “LaTeX Error: \caption outside float”. If you want to send the footnote to the bottom of the page and replace the index with a number rather than a alphabetic character, you may use the minipage*-environment of the footnote package:

\documentclass[12pt]{article}
\usepackage{footnote}
\begin{document}
\begin{minipage*}{6cm}
	\begin{tabular}{|l|c|c|}
		\hline
		A & 1 & 2 \footnote{This is a footnote.} \\
		\hline
		B & 2 & 1 \\
		\hline
		C & 3 & 3 \\
		\hline
	\end{tabular}
\end{minipage*}

The code above places the footnote where and how we want it, but the issue with the caption remains.

What finally saved my day was having a look at the documentation of the footnote package. It provides the savenotes environment, which collects all footnotes inside the tabular where they get stuck and “releases” them at the end. Here is an example:

\documentclass[12pt]{article}
\usepackage{footnote}
\begin{document}
\begin{savenotes}
	\begin{table}[ht]
		\centering
		\begin{tabular}{|l|c|c|}
			\hline
			A & 1 & 2 \footnote{This is the first footnote.} \\
			\hline
			B & 2 & 1 \\
			\hline
			C & 3\footnote{This is the second footnote.} & 3 \\
			\hline
		\end{tabular}
		\caption{A table caption.}
		\end{table}%
	\end{savenotes}
\end{document}

Footnote in table example, result of code.

Footnote in a table.

 

Update: conflict with xcolor package

There is a conflict between the xcolor and the footnote packages. You can fix it by first loading the xcolor package.

The error you will see is either:

Missing } inserted.

or

Extra }, or forgotten \endgroup


20 Responses to “Using footnote in tables”

  • arielsonique

    Thanks for this post. Could you also perhaps summarize the ways you can insert footnotes in the longtable environment? I have been trying to get the footnotes to display directly below where the table ends in the longtable environment but have not been very successful. They end up in the “footnote area”. Also footnotes in various parts of the long table, pre-table text, header text, table cell contents all seem to have different formats. It would be awesome if you could post a bit about it.

    • tom

      Hello! Sorry for the late response. After searching for quite some time, I found a package that allows placing footnotes in a longtable right below the table rather than at the bottom of the page. The package is called threeparttablex and is an extension of the threeparttable package. I changed the example from the documentation to make it a fully functional minimal example. Furthermore, I extended the code for automatic enumeration of the footnotes using a counter which is easily changed to roman, alphabetic, or numeric. Also, the counter is automatically reset when creating a new table.

      By moving the command \insertTableNotes you have the flexibility to place footnotes anywhere you want.

      \documentclass{article}
      \usepackage[referable]{threeparttablex}
      \usepackage{booktabs, longtable}
      \newcounter{tablenote}[table]
      \newcommand{\itemx}[1]{
      	\stepcounter{tablenote}
      	\item[\thetablenote]\label{#1}
      }
      \begin{document}
      \begin{ThreePartTable}
        \begin{TableNotes}
        \itemx{tn:a} test test test
        \itemx{tn:b} Referencing: see note \ref{tn:a}.
        \source Made up by daleif
        \end{TableNotes}
      \begin{longtable}{l l l}
        \caption{A long table}\\
        \toprule
        Coloum 1 & & Column 2\\
        \midrule
        \endhead
        \cmidrule{3-3}
        \multicolumn{3}{r}{\textit{continued}}
        \endfoot
        \bottomrule
        \insertTableNotes\\
        \endlastfoot
        AAAA\tnotex{tn:a} & & BBBB\\
      %  \newpage
        CC & & DD\tnotex{tn:b}\\
      \end{longtable}
      \end{ThreePartTable}
      \end{document}

      Best, Tom.

  • suvayu

    Thanks mate! I spent countless hours trying to get this working before giving up while I was writing my thesis. Next time around, I know where to look. :)

  • docnomore

    I like the minipage environment leaving the footnotes below the figure. However, how is it possible to make this a float?

    • tom

      Hey there,

      Either you pack everything into a floating environment like table which is not very nice. Or you may want to give the threeparttable package a try. Here is an example.

      \documentclass[11pt]{article}
      \usepackage{threeparttable}
      \begin{document}
      \begin{table}
      	\begin{threeparttable}[b]
      	\caption{Table caption.}
      		\begin{tabular}{|l|c|c|c|}
      			\hline
      			First & 42.5\tnote{1}&4.76&2.34\\
      			Second & 43.4&5.3&1.43\\
      			\hline
      		\end{tabular}
      		\begin{tablenotes}
      			\item [1] A table note ...
      		\end{tablenotes}
      	\end{threeparttable}
      \end{table}
      \end{document}

      The ctable package offers similar functionality.

      Best, Tom.

  • Muhammad Naeem

    Good post… I normally use \footnotemark and \footnotetext to add footnotes in table…

    • tom

      Thanks for your comment, Muhammad. I tried, but couldn’t make it work while writing the post. It was only when you wrote your comment, I search a bit more and figured that one has to place the \footnotetext outside the table environment. Here is an example for those who are interested:

      \begin{table}[ht]
      \begin{center}
      \begin{tabular}{|c|c|c|}
      \hline
      Title 1 & Title 2 & Title 3\\
      \hline
      1.234 & 5.687 & 2.234\footnotemark[1]\\
      1.234 & 5.687\footnotemark[2] & 2.234\\
      1.234 & 5.687 & 2.234\\
      \hline
      \end{tabular}
      \end{center}
      \end{table}
      \footnotetext[1]{First footnote at the bottom of the page.}
      \footnotetext[2]{Second footnote at the bottom of the page.}

      Thanks, Tom.

  • John Stowers

    I wonder if the footnotes package fixes the other common limitation – no footnotes in figure (or any) captions

    • tom

      Hey John,

      Thanks for your question. The footnote package allows placing footnotes in captions. However, in you will need to protect them. Otherwise, LaTeX will produce an error message.

      \caption{Figure caption\protect\footnote{Figure caption note.}}

      Cheers, Tom.

      • John Stowers

        Ive been testing this morning, and it seems to break when using hyperref – specifically if using colorlinks=true.

        The following does not work

        \usepackage{footnote}
        \usepackage{hyperref}
        \hypersetup{
            colorlinks=true % false: boxed links; true: colored links
        }
        
      • tom

        Hi John,

        You are right, there is no simple solution for adding hyperlinks to footnote marks within floats. I found a similar question on Stack Exchange. The rather “creative” solution seems to work well, even with colorlinks=true.

        Btw, you can load the hyperref package with options, e.g.:

        \usepackage[colorlinks=true]{hyperref}

        Best, Tom.

  • JoJo

    you make my day.
    Thank you

  • Linda

    Hi Tom!
    Could you give an example on how to write a line type in a figure caption? for example

    \caption{“dashed” refer to bla..bla..and “dotdash” refer to bla..bla..}

    where the ” ” are examples of the line type

    Many thank in advance

    • tom

      Hey Linda,

      Easiest would be to just use the math-environement and write out the line, e.g.:

      \caption{$---$ refer to bla..bla..and $\cdot-\cdot-\cdot$ refer to bla..bla..}

      If you are looking for a more consistent way in terms of line length, try the dashrule package:

      \usepackage{dashrule}
      ...
      \caption{\hdashrule[0.5ex]{2cm}{1pt}{3mm} blabla; \hdashrule[0.5ex]{2cm}{1pt}{3mm 3pt 1pt 3pt} blabla}

      Best, Tom

  • Pawel Müller

    Hi there,

    many thx for this article. I’m writing my master theses and would like to have a footnote in my table.
    None of the above works though, and I really don’t know why. It is something with the other packages I asume, as your reduced example works great. Even with my own table.
    Before I try to fix that, maybe someone of you had the same experience and can help. I get a lot of the following errors:

    Latex Error: ./chapters/materials.tex:97 Extra }, or forgotten \endgroup.
    Latex Error: ./chapters/materials.tex:97 Missing } inserted.

    All in the same line. This is the line where my footnote statement is.
    Any ideas?

    best
    Pawel

    • Pawel Müller

      Hi,
      sorry. My fault. I read about hyperref making it all go down the river, but forgot, that I also use that package… Have to look for something else.

      BTW: I used threeparttable package. It worked fine, but all footnotes which cause a line break in the footnote of the table cause a very strange behavior: The hole table ends up in the footnote area. Any ideas?

  • Pawel Müller

    Hi,

    everything is fine now. I installed the tablefootnote package. It works, although sometimes a footnote is on the wrong page. But I will deal with that in the end.

    best
    Pawel

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 316 other followers