![如何保持三部分表的表注释中多行项的恒定缩进?](https://linux22.com/image/436994/%E5%A6%82%E4%BD%95%E4%BF%9D%E6%8C%81%E4%B8%89%E9%83%A8%E5%88%86%E8%A1%A8%E7%9A%84%E8%A1%A8%E6%B3%A8%E9%87%8A%E4%B8%AD%E5%A4%9A%E8%A1%8C%E9%A1%B9%E7%9A%84%E6%81%92%E5%AE%9A%E7%BC%A9%E8%BF%9B%EF%BC%9F.png)
以下是一个说明性的 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
尝试插入项目tablenotes
(parbox
第一种可能性):
\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}