4

I am using threeparttable to generate a table with notes. However, the a referring to the note is placed outside the table, see picture below. How can I make the note appear inside the table?

enter image description here

\documentclass[11pt]{article} 
\usepackage[flushleft]{threeparttable}
\usepackage{booktabs}
\begin{document}

\begin{table}[ht] \centering \begin{threeparttable} \caption{A table} \begin{tabular}{@{}ll@{}} \toprule Column 1 & Column 2 \tnote{a} \ \midrule Row 1 & X \ Row 2 & X \ \bottomrule \end{tabular} \begin{tablenotes} \small \item[a] Some note. \end{tablenotes} \end{threeparttable} \end{table} \end{document}

arina
  • 51

3 Answers3

5

For information, {NiceTabular} of nicematrix has its own system for tabular notes. In that environment, you can make the a protruding the right margin (when there is strictly nothing between the end of the command \tabularnote and the end of the cell) or not.

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

\begin{document}

\begin{table}[ht] \centering \caption{A table} \begin{NiceTabular}{@{}ll@{}} \toprule Column 1 & Column 2\tabularnote{Some Note} \ \midrule Row 1 & X \ Row 2 & X \ \bottomrule \end{NiceTabular} \end{table}

\begin{table}[ht] \centering \caption{A table} \begin{NiceTabular}{@{}ll@{}} \toprule Column 1 & Column 2\tabularnote{Some Note}\ \midrule Row 1 & X \ Row 2 & X \ \bottomrule \end{NiceTabular} \end{table}

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

F. Pantigny
  • 40,250
5

One way to fix the spacing issue is to append \hphantom{\textsuperscript{a}} to \tnote{a}.

enter image description here

\documentclass[11pt]{article}
\usepackage[flushleft]{threeparttable}
\usepackage{booktabs}
\begin{document}

\begin{table}[ht] \centering \begin{threeparttable} \caption{A table} \begin{tabular}{@{}ll@{}} \toprule Column 1 & Column 2\tnote{a}\hphantom{\textsuperscript{a}} \ \midrule Row 1 & X \ Row 2 & X \ \bottomrule \end{tabular} \begin{tablenotes} \small \item[a] Some note. \end{tablenotes} \end{threeparttable} \end{table} \end{document}

Mico
  • 506,678
4

With talltblr table defined in tabularray package you will not have this problem:

\documentclass[11pt]{article}
\usepackage{tabularray}
\usepackage{booktabs}
\begin{document}
    \begin{table}[ht]
    \centering
\begin{talltblr}[
    caption={A table},
    label = {tab:talltblr},
    note{a} = {Some note}
                ]{hline{1,Z} = 1pt, hline{2} = 0.6pt,
                  colspec={@{} ll @{}},
Column 1 & Column 2\TblrNote{a} \\
 Row 1    & X \\
 Row 2    & X \\
\end{talltblr}
    \end{table}
\end{document}

enter image description here

Zarko
  • 296,517
  • I think something went wrong. You placed this line double: ]{hline{1,Z} = 1pt, hline{2} = 0.6pt, – Elise Jan 19 '22 at 18:33
  • @Elise, you are right, One line is by mistake copied twice in MWE. Now is removed. Thank you for note. Do you for this error down-vote the answer? – Zarko Jan 19 '22 at 18:47
  • I have removed the down-vote, because the answer is helpful now! By the way, the last bracket } after the ..ll @{}}, is also missing. – Elise Jan 20 '22 at 14:00