How to place a footnote inside a float environment

How can one declare a footnote within a float environment, such that it appears on the same page with the float (regularly on the page, not inside the float)? Is there any trick or additional package apart from the widely used workaround

% Let 'floatenv' be any float environment such as figure or table
\begin{floatenv}
[...] \footnotemark [...]
\end{floatenv}

\footnotetext{<text>}


which already fails if the float is put on a dedicated float-page ({floatenv}[p])?

-
Don't footnote floats. Your reader won't know where the footnote comes from. –  egreg Sep 29 '11 at 13:49
I don't know what way round you read footnotes, but imho the idea is that you first see the footnote mark and then look for the footnote and not the other way round. –  barbaz Sep 29 '11 at 13:54
floatenv is just a placeholder for any float environment and not an actual float environment, right? If so, thumbs up for abstracting from your problem, but it probably should be mentioned that this won't compile because the floatenv environment isn't defined. –  doncherry Sep 29 '11 at 15:17

Your question about having footnotes within a float environment allows several interpretations.

First, if the footnote mark needs to be placed inside the float's caption, the short answer is: It can't be done. Well, some TeX wizard might be able to figure out how to do it, but LaTeX's standard footnote mechanisms won't print the footnote text (even though it will print the footnote mark). :-(

Second, for a footnote that should appear at the bottom of the page (as opposed to at the bottom of the float) and should be numbered in the same style as the other footnotes of the document, use the command \footnotemark{} where you want the footnote's "label" (e.g., a raised number "1") to be placed and the command \footnotetext{...} at the end of the float, as in the following MWE. AFAIK, this method only works for a single footnote and may therefore be only of limited interest.

\documentclass{article}
\begin{document}
\section{Start}
\begin{figure}[h]
\caption{Some figure} \label{fn:text}
\centering
Some stuff.\footnotemark{} Some more stuff.
\end{figure}\footnotetext{Text of footnote.}
\end{document}


Aside: if the float is to be displayed on a page of its own, load the afterpage package in the preamble, omit the position specifier ([b] or [p], say) and "encase" the float in an \afterpage{...} construct, as in

\begin{afterpage}{
\begin{table}
...
\end{table}
\footnotetext{...}
\clearpage  % the \clearpage command forces the float to occur on a page by itself.
}  %% end of \afterpage{...} "wrapper"


Third, if the float is a figure, the method described by @AndreyVihrov in his answer -- to embed the body of the figure in a minipage -- works fine. Note that the footnote marks will "numbered" a, b, etc and will be placed at the bottom of the float. When using this method, it's generally a good idea to place the float either at the bottom of the page (so that the float's footnotes also show up at the bottom of the page, "where they belong") or on a page by itself.

Fourth, if the float in question is a table, you have an additional choice (besides the minipage method noted in the preceding paragraph) which may be especially useful if you have lots of footnotes and/or repeated callouts to the same footnote: the threeparttable package. (See this site this page for the documentation of this package.) With this package loaded in the preamble, your float code would look something like

\begin{threeparttable} %% instead of "\begin{table}"
\caption{Some table}
\begin{tabular}{...} %% or tabular*, tabularx, tabulary, ...
...
Some material\tnote{a}\\  %% note the "\tnote" command
More material\tnote{a}\\
...
Still more material\tnote{b}\\
...
\end{tabular} %% or tabular*, tabularx, tabulary, ...
\begin{tablenotes}
\item[a] Footnote "a".
\item[b] Footnote "b".
\end{tablenotes}
\end{threeparttable}


A cool aspect of this package is that if each footnote's text is fairly short, you can use the [para] option, as in

\begin{tablenotes}[para]


to instruct LaTeX to typeset all table footnotes in "paragraph" style.

-
Simply using footnotes in the caption of a figure doesn't work for me. The footnote mark is generated and displayed, but the text does not appear anywhere. –  barbaz Sep 29 '11 at 15:17
You're right; I've corrected my answer accordingly. –  Mico Sep 29 '11 at 15:50
Well, "Second" - which is what I am asking for, a regular footnote on the bottom of the page with the mark within a floating environment - is what i already described in my question and what does not work properly. As the float floats around, the footnotetext won't. And there is also no way to get it on the same page with the float itself if the float is on a floatpage, i.e. it does not work with {figure}[p] for example. Still, thumbs up for a compilation of more workarounds, might help others. –  barbaz Sep 29 '11 at 16:06
Please note that issue of the footnote text not showing up on the same page as the float is easily solved by loading the afterpage package in the preamble and "encasing" the entire float as follows: \afterpage{\begin{table}[p] ... \footnotemark{} ... \end{table} \footnotetext{Bla.}}. I hope this helps. –  Mico Sep 29 '11 at 16:14
Wow, that was by far the most promising answer. Unfortunately it also does not work. If the figure appears on a floatpage, the footnotetext still ends ob on another page. Additionally, wraping some figures in \afterpage{} seems to completely mess up their order :( –  barbaz Sep 29 '11 at 16:24

I use the following solution for cases where the float ends up on a page by itself. In other cases, I have found Mico's solution using \afterpage to work reliably.

I assume you want the float's footnotes to follow the same ordering as other footnotes in the document.

This solution as written requires you to manually enter the number of footnotes in your float if you have more than one, and change this number if you add or remove footnotes. However, by putting everything in a minipage, it gives you precise control over layout where desired (for instance, adjusting distance of footnotes from the bottom of the float contents).

After defining the command \mpfootnotes, put the contents of the float in a minipage. At the end the minipage, put the command \mpfootnotes[n] (where n is the number of footnotes) followed by regular footnotes. The footnotes can be used normally as, for instance, with features provided by footmisc.

\documentclass{article}
\makeatletter
\usepackage[bottom]{footmisc}

\newcommand{\mpfootnotes}[1][1]{
\renewcommand{\thempfootnote}{\thefootnote}
\renewcommand{\footnote}{\stepcounter{footnote}\footnotetext[\value{footnote}]}}

\makeatother
\begin{document}
\begin{figure}
\begin{minipage}[t]{1\columnwidth}
First footnote mark goes here.\footnotemark{}
Another footnote mark goes here.\footnotemark{}
Another instance of the second footnote mark.\footref{fn:note2}
\caption{Figure caption.}

\mpfootnotes[2]
\footnote{The first footnote.}
\footnote{\label{fn:note2}The second footnote.}
\end{minipage}
\end{figure}
\end{document}


A nice feature of this solution is that it's very convenient to use in LyX, with only the footnote marks and the \mpfootnotes command in ERT.

-
Perhaps you should provide a complete working example. –  Christian Hupfer Jun 12 at 22:27
Changed to provide a complete working example. –  tcoffee Jun 12 at 23:17

The solution from Mirco works fine together with the tablefootnote package. Tablefootnote solves the Problem of setting a footnote inside the table (you do not have to use footnotemark and footnotetext anymore) but not the problem that the footnote is set first and then the floating environment table. This means a footnote can appear earlier than the table with the footnotemark. Including the whole Table definition inside \afterpage{Tabledefinition} solves this. The Table can float and the footnote is set on the page the floating environment is set.

-
I don't see that this necessarily solves the problem, since built-up floats can actually occur after the page (to which \afterpage is referring to) and then actually be delayed yet another page. –  Werner Jun 4 '12 at 20:38