如何保持三部分表的表注释中多行项的恒定缩进?

如何保持三部分表的表注释中多行项的恒定缩进?

以下是一个说明性的 MWE:

\documentclass[fontsize=11pt]{article}
\usepackage{blindtext}
\usepackage[flushleft]{threeparttable}
\usepackage{booktabs}


\begin{document}
\blindtext
\begin{table}
\centering
 \begin{threeparttable}
    \begin{tabular}{cc}
    \toprule
    A & B \\
    \midrule
    1234 & 2\tnote{a} \\
    3234 & 4 \\
    5234 & 6\tnote{b} \\
    7234 & 8 \\
    9234 & 10\tnote{c} \\
    11234 & 12 \\
    13234 & 14\tnote{d} \\
    \bottomrule
    \end{tabular}
    \begin{tablenotes}\scriptsize
    \item[a]Test for number 2.
    \item[b]Test for number 6.
    \item[c]Test for number 10.
    \item[d]Test for number 14.
    \end{tablenotes}
 \end{threeparttable}
\end{table}

\end{document}

如果在序言中添加类似这样的内容,也许可以实现:

\usepackage{etoolbox}
\makeatletter
\patchcmd\TPTdoTablenotes{%
  \TPTnoteSettings
}{%
  \TPTnoteSettings
  \setlength{\itemindent}{0pt}%
  \setlength{\labelindent}{0pt}%
  \setlength{\labelwidth}{0pt}%
  \setlength{\labelsep}{0pt}%
  \setlength{\leftmargin}{0pt}%
  \setlength{\itemsep}{2pt}% % VERTICAL SPACING BETWEEN ITEMS
}{}{\errmessage{Patching \noexpand\TPTdoTablenotes failed}}
\makeatother

... 但我还不确定如何使用这些选项。

答案1

尝试插入项目tablenotesparbox第一种可能性):

    \begin{tablenotes}[flushleft]\scriptsize
    \item[a] \parbox[t]{\dimexpr\linewidth-1em}{Test for number 2.}
    \item[b] \parbox[t]{\dimexpr\linewidth-1em}{Test for number 6.}
    \item[c] \parbox[t]{\dimexpr\linewidth-1em}{Test for number 10.}
    \item[d] \parbox[t]{\dimexpr\linewidth-1em}{Test for number 14.}
    \end{tablenotes}

在此处输入图片描述

附录:

您可以使用选项online,根据需要更改项目标签的显示内容并编写项目文本:

\documentclass[fontsize=11pt, paper=a4, DIV=10, BCOR=8mm, oneside]{scrreprt}
\usepackage{blindtext}
\usepackage[flushleft]{threeparttable}
\usepackage{booktabs}


\begin{document}
\blindtext
\begin{table}[ht]
\centering
 \begin{threeparttable}
%\caption{Test for the tnote in a threeparttable}
    \begin{tabular}{cc}
    \toprule
    A & B \\
    \midrule
    1234 & 2\tnote{a} \\
    3234 & 4 \\
    5234 & 6\tnote{b} \\
    7234 & 8 \\
    9234 & 10\tnote{c} \\
    11234 & 12 \\
    13234 & 14\tnote{d} \\
    \bottomrule
    \end{tabular}
    \begin{tablenotes}[flushleft, online]\scriptsize\raggedright % <---
    \item[a] Test for number 2.
    \item[b] Test for number 6.
    \item[c] Test for number 10.
    \item[d] Test for number 14.
    \end{tablenotes}
 \end{threeparttable}
\end{table}

\end{document}

在此处输入图片描述

编辑: 在编辑问题时,您提供了可能的解决方案的建议。如果您按如下方式更改其中的设置。如果项目的标签短于 1.em(大约三个\scriptsize字母),则它可以正常工作:

\documentclass[fontsize=11pt, paper=a4, DIV=10, BCOR=8mm, oneside]{scrreprt}
\usepackage{blindtext}
\usepackage{ragged2e}
\usepackage{booktabs}
\usepackage[flushleft]{threeparttable}
\usepackage{etoolbox}       % <---
\patchcmd\TPTdoTablenotes{%   <---
  \TPTnoteSettings
}{%
  \TPTnoteSettings
  \setlength{\labelwidth}{0.7em}% <---
  \setlength{\leftmargin}{\labelwidth}% <---
  \setlength{\itemsep}{2pt}% 
}{}{\errmessage{Patching \noexpand\TPTdoTablenotes failed}}

\begin{document}
\blindtext
    \begin{table}[ht]
\centering
\begin{threeparttable}
%\caption{Test for the tnote in a threeparttable}
    \begin{tabular}{cc}
    \toprule
    A & B \\
    \midrule
    1234 & 2\tnote{a} \\
    3234 & 4 \\
    5234 & 6\tnote{b} \\
    7234 & 8 \\
    9234 & 10\tnote{c} \\
    11234 & 12 \\
    13234 & 14\tnote{d} \\
    \bottomrule
    \end{tabular}
    \begin{tablenotes}[flushleft]\scriptsize\raggedright
    \item[a] Test for number 2.
    \item[bbb] Test for number 6.
    \item[c] Test for number 10.
    \item[d] Test for number 14.
    \end{tablenotes}
\end{threeparttable}
    \end{table}
\end{document}

在此处输入图片描述

答案2

我将使用新的 LaTeX3 包为长表格提供解决方案tabularray

\documentclass[fontsize=11pt]{article}

\usepackage{blindtext}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\begin{document}
\blindtext
\begin{longtblr}[
  caption = {Title},
  note{a} = {Test for number 2 number 2},
  note{b} = {Test for number 6 number 6},
  note{c} = {Test for number 10 number 10},
  note{d} = {Test for number 14 number 14},
]{colspec={XX},width=0.25\linewidth}
\toprule
  A & B \\
\midrule
   1234 &  2\TblrNote{a} \\
   3234 &  4             \\
   5234 &  6\TblrNote{b} \\
   7234 &  8             \\
   9234 & 10\TblrNote{c} \\
  11234 & 12             \\
  13234 & 14\TblrNote{d} \\
\bottomrule
\end{longtblr}

\end{document}

在此处输入图片描述


我将根据@Euclides 的要求添加另一个示例:

\documentclass[fontsize=11pt]{article}
\usepackage[paperwidth=8cm,paperheight=9cm,width=6cm,height=7cm]{geometry}

\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\SetTblrStyle{note-tag}{font=\rmfamily}

\begin{document}
Text Text Text Text Text Text Text.
\begin{longtblr}[
  caption = {Title},
  note{a} = {Test for number 2 number 2 number 2},
  note{b} = {Test for number 6 number 6 number 6},
  note{c} = {Test for number 10 number 10 number 10},
  note{d} = {Test for number 14 number 14 number 14},
]{colspec={XX},width=0.8\linewidth,rowhead=1}
\toprule
  A & B \\
\midrule
   1234 &  2\TblrNote{a} \\
   3234 &  4             \\
   5234 &  6\TblrNote{b} \\
   7234 &  8             \\
   9234 & 10\TblrNote{c} \\
  11234 & 12             \\
  13234 & 14\TblrNote{d} \\
   1234 &  2\TblrNote{a} \\
   3234 &  4             \\
   5234 &  6\TblrNote{b} \\
   7234 &  8             \\
   9234 & 10\TblrNote{c} \\
  11234 & 12             \\
  13234 & 14\TblrNote{d} \\
   1234 &  2\TblrNote{a} \\
   3234 &  4             \\
   5234 &  6\TblrNote{b} \\
   7234 &  8             \\
   9234 & 10\TblrNote{c} \\
  11234 & 12             \\
  13234 & 14\TblrNote{d} \\
   1234 &  2\TblrNote{a} \\
   3234 &  4             \\
   5234 &  6\TblrNote{b} \\
   7234 &  8             \\
   9234 & 10\TblrNote{c} \\
  11234 & 12             \\
  13234 & 14\TblrNote{d} \\
\bottomrule
\end{longtblr}

\end{document}

在此处输入图片描述

答案3

供参考,以下是您可以使用{NiceTabular}ofnicematrix及其内置命令执行的操作\tabularnote

\documentclass[fontsize=11pt]{article}
\usepackage{blindtext}
\usepackage{booktabs}
\usepackage{enumitem}
\usepackage{nicematrix}

\begin{document}
\blindtext
\begin{table}
\NiceMatrixOptions{notes/code-before=\scriptsize}
\centering
    \begin{NiceTabular}{cc}
    \toprule
    A & B \\
    \midrule
    1234 & 2\tabularnote{Test for number 2.}\\
    3234 & 4 \\
    5234 & 6\tabularnote{Test for number 6.}\\
    7234 & 8 \\
    9234 & 10\tabularnote{Test for number 10.}\\
    11234 & 12 \\
    13234 & 14\tabularnote{Test for number 14.}\\
    \bottomrule
    \end{NiceTabular}
\end{table}

\end{document}

上述代码的输出

相关内容