当我们使用 threeparttable 包时,tabular 和 tablenotes 环境之间会插入多少垂直空间?我正在尝试构建一个tablenotes
看起来类似于 Beamer 的环境,threeparttable
但没有 Beamer 中的大部分花哨功能,它不太适合threeparttable
唉,我发现很难解开源代码threeparttable
。
以下 MWE 显示了当我使用tablenotes
环境和使用简单\raggedright
段落时表格和注释之间的垂直间距有何不同。
\documentclass{article}
\usepackage[para,flushleft]{threeparttable}
\usepackage{booktabs}
\usepackage{tabularx}
\begin{document}
\begin{table}[h]
\begin{threeparttable}
\caption{With \texttt{tablenotes} environment}
\begin{tabularx}{\linewidth}{@{}Xccc@{}}
\toprule
& A & B & C \\
\midrule
First row heading & 123 & 456 & 789 \\
Second row heading & 123 & 456 & 789 \\
Third row heading & 123 & 456 & 789 \\
\bottomrule
\end{tabularx}
\begin{tablenotes}
\emph{Note:} Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
\end{tablenotes}
\end{threeparttable}
\end{table}
\clearpage
\begin{table}[h]
\begin{threeparttable}
\caption{Without \texttt{tablenotes} environment}
\begin{tabularx}{\linewidth}{@{}Xccc@{}}
\toprule
& A & B & C \\
\midrule
First row heading & 123 & 456 & 789 \\
Second row heading & 123 & 456 & 789 \\
Third row heading & 123 & 456 & 789 \\
\bottomrule
\end{tabularx}
\raggedright \emph{Note:} Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod\par
\end{threeparttable}
\end{table}
\end{document}
答案1
您可以尝试使用talltblr
环境(在版本中2021M
添加2021-08-01
)tabularray
包。有一个footsep
用于设置此垂直空间的选项:
\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\begin{document}
With \texttt{talltblr} environment, default \texttt{footsep = 6pt}:
\begin{table}[h]
\begin{talltblr}[
caption = {With \texttt{talltblr} environment},
remark{Note} = {Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod},
]{@{}Xccc@{}}
\toprule
& A & B & C \\
\midrule
First row heading & 123 & 456 & 789 \\
Second row heading & 123 & 456 & 789 \\
Third row heading & 123 & 456 & 789 \\
\bottomrule
\end{talltblr}
\end{table}
With \texttt{talltblr} environment, set \texttt{footsep = 0pt}:
\begin{table}[h]
\begin{talltblr}[
caption = {With \texttt{talltblr} environment},
remark{Note} = {Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod},
footsep = 0pt,
]{@{}Xccc@{}}
\toprule
& A & B & C \\
\midrule
First row heading & 123 & 456 & 789 \\
Second row heading & 123 & 456 & 789 \\
Third row heading & 123 & 456 & 789 \\
\bottomrule
\end{talltblr}
\end{table}
\end{document}
相同的源代码也适用于beamer
文档:
答案2
环境{NiceTabular}
有自己的表格注释系统。通过在键的内容中nicematrix
放置命令,可以轻松设置表格注释前的垂直空间。\vspace
tabularnote
\documentclass{article}
\usepackage{nicematrix,booktabs,enumitem}
\begin{document}
\begin{table}[h]
\begin{NiceTabular}
[tabularnote = {\vspace{5pt}Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod}]
{@{}Xccc@{}}
\toprule
& A & B & C \\
\midrule
First row heading & 123\tabularnote{A note}& 456 & 789 \\
Second row heading & 123\tabularnote{A second note}& 456 & 789 \\
Third row heading & 123 & 456 & 789 \\
\bottomrule
\end{NiceTabular}
\end{table}
\end{document}
该包的主要缺点nicematrix
是创建的表格{NiceTabular}
不能被破坏(例如在longtable
或中tabularray
)。