使用 threeparttable 的 tabular 和 tablenotes 环境之间的垂直空间是多少?

使用 threeparttable 的 tabular 和 tablenotes 环境之间的垂直空间是多少?

当我们使用 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}

MWE 的动画输出

答案1

您可以尝试使用talltblr环境(在版本中2021M添加2021-08-01tabularray包。有一个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放置命令,可以轻松设置表格注释前的垂直空间。\vspacetabularnote

\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)。

相关内容