4

I want to use footnote inside a table and I have a table that looks like this (simplified for brevity):

\documentclass[a4paper]{paper}
\begin{document}

\begin{table}[h]
\centering
\resizebox{\textwidth}{!}{
\begin{tabular}{|*{4}{c|}}
\hline
\multirowcell{3}{Work} & \multirowcell{3}{Language} & \multirowcell{3}{Prime} & \multirowcell{3}{Time (ms)} \\ 
\hline \hline
Microsoft \footnote{\url{https://github.com/Microsoft/PQCrypto-SIDH}} & C & $2^{372}3^{239} - 1$ &  \\ \hline
Cloudflare \footnote{\url{https://github.com/cloudflare/p751sidh}} & Go & $2^{372}3^{239} - 1$ &    \\ \hline
\end{tabular}}
\caption{Comparison}
\label{tab:comp}
\end{table}

\end{document}

This shows the footnote numbers, but the footnote text is not appearing at the bottom of the page. I tried some solutions from here, but didn't succeed with anything. Any ideas what the problem might be and how to correct it?

pixel
  • 1,357

3 Answers3

4

If you want the footnotes to appear with the table, you can include everything in a minipage of the appropriate width.

\documentclass[a4paper]{paper}
\usepackage{url}
\usepackage{multirow}
\usepackage{makecell}
\begin{document}
\begin{table}[h]
\begin{minipage}{\textwidth} % so footnote will appear
\renewcommand*\footnoterule{}
\centering
\begin{tabular}{|*{4}{c|}}
\hline
\multirowcell{1}{Work} & \multirowcell{1}{Language} & \multirowcell{1}{Prime} & \multirowcell{1}{Time (ms)} \\ 
\hline \hline
Microsoft\footnote{\url{https://github.com/Microsoft/PQCrypto-SIDH}}  & C & $2^{372}3^{239} - 1$ &  \\ \hline
Cloudflare\footnote{\url{https://github.com/cloudflare/p751sidh}}  & Go & $2^{372}3^{239} - 1$ &    \\ \hline
\end{tabular}
\end{minipage}
\caption{Comparison}
\label{tab:comp}
\end{table}
\end{document}

enter image description here

erik
  • 12,673
3

The main problem can be solved by using \footnotemark and \footnotetext separately.

Some other comments:

  • Several packages are missing

  • please do not use \resizebox for tables, choose an appropriate fontsize instead, see Why not scale elements that contain text for some explanation

  • your first row had too many entries, 4 times 3 = 12 cells!


\documentclass[a4paper]{paper}

\usepackage{url}
\usepackage{multirow}
\usepackage{makecell}

\newcounter{footnotesintable}

\begin{document}

\footnote{bla}

\begin{table}[htbp]
\centering
\setcounter{footnotesintable}{0}
\begin{tabular}{|*{4}{c|}}
\hline
\multirowcell{1}{Work} & \multirowcell{1}{Language} & \multirowcell{1}{Prime} & \multirowcell{1}{Time (ms)} \\ 
\hline \hline
Microsoft \addtocounter{footnote}{1}\addtocounter{footnotesintable}{1}\footnotemark[\thefootnote]  & C & $2^{372}3^{239} - 1$ &  \\ \hline
Cloudflare \addtocounter{footnote}{1}\addtocounter{footnotesintable}{1}\footnotemark[\thefootnote]  & Go & $2^{372}3^{239} - 1$ &    \\ \hline
\end{tabular}
\caption{Comparison}
\label{tab:comp}
\end{table}

\addtocounter{footnote}{-\thefootnotesintable}
\addtocounter{footnote}{1}\footnotetext[\thefootnote]{\url{https://github.com/Microsoft/PQCrypto-SIDH}}
\addtocounter{footnote}{1}\footnotetext[\thefootnote]{\url{https://github.com/cloudflare/p751sidh}}


\footnote{bla}
\end{document}
3

You can use a longtable environment. Don't use \resizebox for tables, as it leads to inconsistent font sizes. You can use tabularx or tabular* instead.

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{makecell, tablefootnote, longtable}
\usepackage{url}
\usepackage{hyperref}

 \begin{document}

 \vspace*{15cm}
{\setlength{\extrarowheight}{3pt}
\begin{longtable}{|*{4}{c|}}
\caption{Comparison}
\label{tab:comp}\\
\hline
\endfirsthead
\hline
\endfoot
\multirowcell{3}{Work} & \multirowcell{3}{Language} & \multirowcell{3}{Prime} & \multirowcell{3}{Time (ms)} \\
\hline \hline
Microsoft \footnote{\url{https://github.com/Microsoft/PQCrypto-SIDH}} & C & $2^{372}3^{239} - 1$ & \\ \hline
Cloudflare \footnote{\url{https://github.com/cloudflare/p751sidh}} & Go & $2^{372}3^{239} - 1$ &
\end{longtable}}

\end{document} 

enter image description here

Bernard
  • 271,350
  • Thanks for the nice answer. If I use tabularx or tabular*, then how can I use the footnotes? I mean do I also have to embed the longtable inside it? Since my tables are long (I partially removed them for brevity), I need a good way to fit them inside the margin. I didn't know that \resizebox is problematic. – pixel Apr 02 '18 at 14:08
  • For \ tabularx, you can load theltablexpackage, which makes tabularx a longtable, breakable across pages (not tested with footnotes, though). You'll find information on the various possibilities in the (short) documentation of thetablefootnote` package. – Bernard Apr 02 '18 at 14:12