我正在使用 threeparttable 生成带注释的表格。但是,A指的是注释放在表格外面,见下图。如何让注释出现在表格里面?
\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
解决间距问题的一种方法是附加\hphantom{\textsuperscript{a}}
到\tnote{a}
。
\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}
答案2
供参考,{NiceTabular}
ofnicematrix
有自己的表格注释系统。在该环境中,您可以制作A突出右边距(当命令末尾\tabularnote
和单元格末尾之间严格没有任何东西时)或不突出右边距。
\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}
您需要多次编译(因为nicematrix
在后台使用 PGF/Tikz 节点)。
答案3
使用包talltblr
中定义的表,tabularray
您将不会遇到这个问题:
\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}