Sunday, March 30, 2008

Footnotes from floats in LaTeX: problem & solution

(Excerpted from Rhaptos Software Development )

LaTeX has floating environments, of which tables and figures are the most important. Footnotes from within those environments are problematic.

The LaTeX engine will by default move floats around, even onto different pages, in order to achieve optimal horizontal and vertical page layouts. Human book editors and typesetters do the same thing when preparing books for press.

Because of the way the LaTeX engine handles floats, footnotes from within them are problematic. In the normal case, the author inserts a \footnote{} command with the footnote text within the curly braces into the text at the point where the footnote marker should appear:

Example:

This is my blog\footnote{Actually, it is hosted at Google} site.

However, if the author is making a footnote from within a float environment, one inserts a \footnotemark command into the text in the float at the point where the footnote mark should appear, and then after the end of the float, one tacks on a \footnotetext{} command with the text of the footnote in it:

\begin{figure}
\includegraphics{blorgy.png}
\caption{This figure caption has a footnote.\footnotemark}
\end{figure}
\footnotetext{This is the text of the footnote.}

The \footnotemark command increments the footnote counter, so if you have more than one \footnotemark before the \footnotetext{} commands, you have to set the footnote counter back so that the first \footnotetext{} doesn't get the count of the last \footnotemark.

\begin{figure}
\includegraphics{blorgy.png}
\caption{This figure caption has a footnote.\footnotemark}
In fact, it has two.\footnotemark
\end{figure}
\addtocounter{footnote}{-2}
\stepcounter{footnote}\footnotetext{This is the text of the first footnote.}
\stepcounter{footnote}\footnotetext{This is the text of the second footnote.}


And that's it.

3 comments:

Falk said...

I figured out a problem when using your advice in \floatingfigure. In that case the texts of all of the footnotes which are on the same page like the floatingfigure will be placed too close to the bottom of the page. They're even crossing the footsepline! How can I fix that?

Alan Richardson said...

Thanks - a clean explanation, and the first I've found that works well without adding a bunch of imports.

Unknown said...

Thanks!