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}
1

3 Answers 3

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}
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

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

3
  • I think something went wrong. You placed this line double: ]{hline{1,Z} = 1pt, hline{2} = 0.6pt,
    – Elise
    Commented Jan 19, 2022 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
    Commented Jan 19, 2022 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
    Commented Jan 20, 2022 at 14:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .