12

I'm having trouble putting notes below the table - I want to put several notes below the table but the footnote seems to stretch, making the table longer than necessary. Would there be a way to fix this?

\begin{table}[htbp]\centering \caption{Summary Statistics}
\begin{tabular}{l c c c}
\hline\hline
\multicolumn{1}{c}{\textbf{Variable}} & \textbf{Mean} & \textbf{Std. Dev.} & \textbf{N}\\
\hline
a & a & a & a \\
\hline
\label{table2}
\multicolumn{3}{l}{\textsuperscript{*}\footnotesize{blah blah}}
\end{tabular}
\end{table}

Example

strpeter
  • 5,215
halo09876
  • 369

3 Answers3

21

You should use the threeparttable package, that's designed for that sort of things. In the following code, I added the caption package, to ensure a proper spacing between caption and table, booktabs and the makecell package, that allows for common formatting of column heads.

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs, caption, makecell}
\renewcommand\theadfont{\bfseries}
\usepackage{threeparttable}

\begin{document}

\begin{table}[! htbp]\centering \caption{Summary Statistics} \begin{threeparttable} \begin{tabular}{l c c c} \toprule\midrule \thead{Variable} & \thead{Mean} & \thead{Std. Dev.} & \thead{N}\ \midrule a & a & a\tnote{} & a \ \bottomrule\addlinespace[1ex] \end{tabular} \begin{tablenotes}\footnotesize \item[] Blahblah \end{tablenotes} \end{threeparttable} \label{table2} \end{table}

\end{document}

enter image description here

Bernard
  • 271,350
  • Should a \tnote{*} directive be inserted somewhere in the tabular environment? – Mico Nov 12 '14 at 22:16
  • 1
    Yes. As your code didn't contain anything of the sort I didnt put one. Another remark: there is a threepartablex package that works with long tables, that break across pages, and a slightly different syntax. – Bernard Nov 12 '14 at 22:20
  • Hi thanks for the feedback! I actually tried threeparttable but the note below seems to align towards the center rather than as it should in an ordinary text. If the note is short, it is no problem, but my note is long and threeparttable doesn't seem to align the note well. Please see after inputing longer text after \item – halo09876 Nov 13 '14 at 00:48
  • I'll take a look at this and come back in a moment. – Bernard Nov 13 '14 at 01:02
  • @user2298759: I have no such problem. You can try the flushleft option on loading the package. – Bernard Nov 13 '14 at 01:27
  • @Bernard I had trouble because of \bottomrule\addlinespace[1exA] but just doing \bottomrule worked. Thanks! – halo09876 Nov 13 '14 at 23:00
  • @user229759: Sorry, I mistyped \addlinespace[1ex] (no A). Corrected my code. – Bernard Nov 13 '14 at 23:54
  • As a note, in normal booktabs usage, \toprule should be by itself and the \hline should be replaced with \midrule. – JAB Mar 21 '17 at 15:45
  • Hello @Bernard, how can I insert the * below the "Std. Dev." row? In this case I'd like to write a*. – Gennaro Arguzzi Nov 08 '17 at 19:21
  • @GennaroArguzzi: Use \tnote{*} right after the third a. Please see my updated answer – Bernard Nov 08 '17 at 20:26
  • Actually the name of the package that works with long tables is threeparttablex, with a double t. :) – Leone Aug 18 '21 at 00:53
  • @Leone: It is worth mentioning the syntax of threeparttablex is somewhat different from the syntax of threeparttable. – Bernard Aug 18 '21 at 08:10
2

You can also use {NiceTabular} of nicematrix and its built-in command \tabularnote.

\documentclass[12pt]{article}
\usepackage{nicematrix,enumitem,booktabs}

\begin{document}

\begin{table}[htbp] \centering \begin{NiceTabular}{@{}lp{8cm}@{}} \toprule \textbf{Activity} & \textbf{Activity Sequence}\ \midrule Getting on a Tram\tabularnote{Note that \textit{Getting On Sequence} will start from steady standing in the station.}& Standing, Walking, Turn Left or right, walk, climb up stairs, turn left or right, walk again till reach seat, turn left or right $90°$ or $180°$, seat down, sitting for long time. \ Getting off a Tram\tabularnote{Note that \textit{Getting Off Sequence} will start from steady sitting state in the Tram.}& Sitting, stand up, turn left or right $90°$ or $180°$, walk till reach the door, turn left or right to reach stairs, climb down, walk out from the Tram. \ \bottomrule \end{NiceTabular} \caption{Getting on/off passengers' activity states} \label{tab:GettingOnOffPassengersActivityStates} \end{table} \end{document}

Output of the above code

F. Pantigny
  • 40,250
  • This is without question better than the excepted answer, since automatically labelled and hyperreferenced footnotes are supported (as they always should be for any footnote package, else just use MS Word) – pretzlstyle May 12 '22 at 20:58
1
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{threeparttable}
\usepackage{booktabs, caption, makecell}
\renewcommand\theadfont{\bfseries}
\begin{document}

\begin{table}[htbp]
    \begin{minipage}{10cm}
\begin{threeparttable}[t]
    \centering
\begin{tabular}{|c|c|} 
 \hline
\textbf{Activity} & \textbf{Activity Sequence}\\\hline
 Getting on a Tram \tnote{1}& \multicolumn{1}{m{6cm}|}{Standing, Walking, Turn Left or right, walk, climb up stairs, turn left or right, walk again till reach seat, turn left or right 90$^{\circ}$ or 180$^{\circ}$, seat down, sitting for long time.}  \\\hline 
 Getting off a Tram\tnote{2}& \multicolumn{1}{m{6cm}|}{Sitting, stand up, turn left or right 90$^{\circ}$ or 180$^{\circ}$, walk till reach the door, turn left or right to reach stairs, climb down, walk out from the Tram.}  \\ 
 \hline
\end{tabular}
\begin{tablenotes}
     \item[1] Note that \textit{Getting On Sequence} will start from steady standing in the station.
     \item[2] Note that \textit{Getting Off Sequence} will start from steady sitting state in the Tram.
   \end{tablenotes}
\end{threeparttable}
\end{minipage}
    \caption{Getting on/off passengers' activity states}
    \label{tab:GettingOnOffPassengersActivityStates}
\end{table}
\end{document}

enter image description here

Martin Scharrer
  • 262,582
ali mmd
  • 19