[Tex/LaTex] why \usepackage{tablefootnote} puts the footnote at random locations

footnotestables

I wanted to make a footnote in a table. So I used tablefootnote http://www.ctan.org/tex-archive/macros/latex/contrib/tablefootnote to do that as was suggested by google search since normal \footnote do not work inside tables.

However, it seems the actual footnote sometimes shows up at the bottom of the previous page, and sometimes it shows up at the bottom of the next page.

I'd like the footnote to show on the same page.

Example 1, footnote shows up at bottom of previous page

\documentclass[12pt,notitlepage]{article}%
\usepackage{float}%
\usepackage{lipsum}
\usepackage{tablefootnote}

\begin{document}
\section{A}
\lipsum[4-10]
\section{B}
\begin{table}[htp]
\begin{center}
\begin{tabular}{|l|l|l|}\hline
$e$                      & 0.97774    & 0.9935      \\ \hline
semimajor axis $a$       & 300000     & 262413      \\ \hline
true anamoly $f$         & 163.76     & 176.08       \\\hline
semimajor axis $a$       & 300000     & 262413  \\ \hline
true anamoly $f$         & 163.76     & 176.08     \\\hline
$r_p$                    & 6678       & 1689
  \tablefootnote{spacecraft will hit earth on way back since $r_p<r_{earth}$} \\\hline
\end{tabular}
\caption{Summary table for non-tangential per and post flyby the moon}
\label{tab:part_3_1_summary}
\end{center}
\end{table}
\end{document}

Mathematica graphics

Example 2, footnote shows up on next page

\documentclass[12pt,notitlepage]{article}%
\usepackage{float}%
\usepackage{lipsum}
\usepackage{tablefootnote}

\begin{document}
\section{A}
\lipsum[4-6]
\section{B}
\begin{table}[htp]
\begin{center}
\begin{tabular}{|l|l|l|}\hline
semimajor axis $a$       & 300000  & 262413    \\ \hline
true anamoly $f$         & 163.76   & 176.08   \\\hline
$r_p$                    & 6678 & 1689
 \tablefootnote{spacecraft will hit earth on way back since $r_p<r_{earth}$} \\\hline
\end{tabular}
\caption{Summary table for non-tangential per and post flyby the moon}
\label{tab:part_3_1_summary}
\end{center}
\end{table}
\section{C}
\lipsum[4-10]

\end{document}

Mathematica graphics

Miktex 2.9, latest.

Best Answer

Footnotes at the bottom of the page to a float will produce this undesired effect since the float might float away to another page. In case footnotes to tables (or floats, in general) are really required, it's better to use footnotes immediately after the float which can be obtained using, for example the threeparttable or ctable packages.

An exampe using threeparttable:

\documentclass[12pt,notitlepage]{article}%
\usepackage{lipsum}
\usepackage{threeparttable}

\begin{document}

\section{A}
\lipsum[4-6]
\section{B}
\begin{table}
\centering
\begin{threeparttable}
\caption{Summary table for non-tangential per and post flyby the moon}
\label{tab:part_3_1_summary}
\begin{tabular}{|l|l|l|}\hline
semimajor axis $a$       & 300000  & 262413    \\ \hline
true anamoly $f$         & 163.76   & 176.08   \\\hline
$r_p$                    & 6678 & 1689\tnote{1} \\ \hline
\end{tabular}
\begin{tablenotes}
\item[1] spacecraft will hit earth on way back since $r_p<r_{earth}$
\end{tablenotes}
\end{threeparttable}
\end{table}
\section{C}
\lipsum[4-10]

\end{document}

enter image description here

And the same table using ctable:

\documentclass[12pt,notitlepage]{article}%
\usepackage{lipsum}
\usepackage{ctable}

\begin{document}

\section{A}
\lipsum[4-6]
\section{B}
\ctable[
caption = Summary table for non-tangential per and post flyby the moon.
label={tab:part_3_1_summary}
]{|l|l|l|}
{\tnote[1]{spacecraft will hit earth on way back since $r_p<r_{earth}$}}
{
\hline
semimajor axis $a$       & 300000  & 262413  \\ \hline
true anamoly $f$         & 163.76   & 176.08   \\ \hline
$r_p$ & 6678 & 1689 \\ 
\hline
}
\section{C}
\lipsum[4-10]

\end{document}

enter image description here

Both packages offer some customization possibilities for the note formatting; please refer to the documentation of the packages

Related Question