我喜欢在表格下添加简单的注释文本。threeparttable 看起来很有吸引力,因为它非常适合表格。但它只适用于项目注释。添加非列出项目的表格注释的正确方法是什么?
答案1
环境{NiceTabular}
有自己的表格注释系统。具体来说,在主表格后的脚注区域中nicematrix
有一个插入无项目文本的键。tabularnote
\documentclass{article}
\usepackage{nicematrix,booktabs}
\begin{document}
\begin{NiceTabular}{@{}llr@{}}%
[ tabularnote =
Here you can put a text that will be inserted before the potential tabular notes.
]
\toprule
Last name & First name & Birth day \\
\midrule
Achard
& Jacques & June 5, 2005 \\
Lefebvre
& Mathilde & January 23, 1975 \\
Vanesse & Stephany & October 30, 1994 \\
Dupont & Chantal & January 15, 1998 \\
\bottomrule
\end{NiceTabular}
\end{document}
还有一个键是在注释后面notes/bottomrule
添加\bottomrule
(包裹的)。booktabs
\documentclass{article}
\usepackage{nicematrix,booktabs}
\begin{document}
\begin{NiceTabular}{@{}llr@{}}%
[ notes/bottomrule,
tabularnote =
Here you can put a text that will be inserted before the potential tabular notes.
]
\toprule
Last name & First name & Birth day \\
\midrule
Achard
& Jacques & June 5, 2005 \\
Lefebvre
& Mathilde & January 23, 1975 \\
Vanesse & Stephany & October 30, 1994 \\
Dupont & Chantal & January 15, 1998 \\
\bottomrule
\end{NiceTabular}
\end{document}
答案2
通过包talltblr
中的定义,tabularray
这可以简单实现:
\documentclass{article}
\usepackage{microtype}
\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\usepackage{lipsum}
\begin{document}
\begin{table}[ht]
\sisetup{table-format=-1.2{***},
input-close-uncertainty=,
input-open-uncertainty=,
round-mode = places,
round-precision = 2
}
\centering
\SetTblrStyle{note}{font=\small, fg=red}
\begin{talltblr}[
caption = {Effect of x on y},
note{} = {\lipsum[66]}
]{colspec={l *{2}{S S[table-format={(}1.2{(}]}},
row{1-2,X,Y,Z} = {guard},
}
\toprule
& \SetCell[c=2]{c} $y_1$
& & \SetCell[c=2]{c} $y_2$
& \\
\cmidrule[r]{2-3} \cmidrule[l]{4-5}
& (1) & (2) & (1) & (2) \\
\midrule
1.x & 0.03** & (0.157) & 0.03* & (0.62) \\
1.hg & 0.16 & (0.84) & & \\
1.f\#1.hg & -0.6* & (0.8) & & \\
1.i & 0.9 & (0.30) & -0.1 & (0.36) \\
\cmidrule[r]{2-3} \cmidrule[l]{4-5}
N & \SetCell[c=2]{c} 500
& & \SetCell[c=2]{c} 455
& \\
FE & \SetCell[c=2]{c} Yes
& & \SetCell[c=2]{c} Yes
& \\
Control & \SetCell[c=2]{c} Yes
& & \SetCell[c=2]{c} Yes
& \\
\bottomrule
\end{talltblr}
\end{table}
\end{document}
(表格示例取自我的答案)。请注意,下表以红色突出显示,您可以将其更改为其他颜色,例如灰色,或通过从中删除来使用默认的fg=red
黑色\SetTblrStyle{note}{...}
。