为什么我的 threeparttable 表格的边框会突出?这里如何(自动)调整宽度?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabulary}
\usepackage{threeparttable}
\usepackage{array}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{lipsum}
\renewcommand{\arraystretch}{1.2}
\sisetup{round-mode=places,round-precision=1, add-decimal-zero=true, add-integer-zero=true, round-integer-to-decimal}
\begin{document}
\lipsum[1]
\begin{table}
\centering
\begin{threeparttable}
\caption{Some long boring caption don't fall asleep 2013}
\begin{tabulary}{\textwidth}{@{}*{1}{l}*{2}{S[table-format=3.2]}@{}}
\toprule
& {incl.\ Ingredients A\tnote{1a}} & {excl.\ Ingredients A\tnote{1b}} \\
\midrule
DDDDDDDDDDD & 36.1 & 22.0\\
GGGGGGGGGGGG & 30.9 & 20.0\\
GGGG\tnote{2} & 33.0 & 22.8\\
OOOO\tnote{2} & 33.766 & 24.643
\\ \bottomrule
\end{tabulary}
\begin{tablenotes}
\item [2] Unweighted Average
\item [] Source: radiowaves from outer space 1999
\end{tablenotes}
\end{threeparttable}
\end{table}
\lipsum[2]
\end{document}
答案1
\tnote
将其参数排版在零宽度框中,因此不会影响数据的排版。这可能在标题或描述中是不需要的;您可以添加一个模仿工作\tnote
但使用全宽的命令。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabulary}
\usepackage{threeparttable}
\usepackage{array}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{lipsum}
\renewcommand{\arraystretch}{1.2}
\sisetup{round-mode=places,
round-precision=1,
add-decimal-zero=true,
add-integer-zero=true,
round-integer-to-decimal}
% This is like `\tnote`, but uses the space of the argument
\newcommand\stnote[1]{\textsuperscript{\TPTtagStyle{#1}}}
\begin{document}
\lipsum[1]
\begin{table}[ht]
\centering
\begin{threeparttable}
\caption{Some long boring caption don't fall asleep 2013}
\begin{tabulary}{\textwidth}{@{} L *{2}{S[table-format=3.2]}@{}}
\toprule
& {incl.\ Ingredients A\stnote{1a}} & {excl.\ Ingredients A\stnote{1b}} \\
\midrule
DDDDDDDDDDD & 36.1 & 22.0 \\
GGGGGGGGGGGG & 30.9 & 20.0 \\
GGGG\tnote{2} & 33.0 & 22.8 \\
OOOO\tnote{2} & 33.766 & 24.643 \\
\bottomrule
\end{tabulary}
\begin{tablenotes}
\item [2] Unweighted Average
\item [] Source: radiowaves from outer space 1999
\end{tablenotes}
\end{threeparttable}
\end{table}
\lipsum[2]
\end{document}
请注意,为了做一些明智的事情,tabulary
您必须至少添加一个“未确定宽度的列”,LCRJ
每个字符指定一个字符,表示列单元格中所需的对齐方式:左对齐(右侧参差不齐)、居中、右对齐(左侧参差不齐)、两端对齐。
稍微不同的定义允许\stnote
在标题中使用而不出现在表格列表中:将定义更改\stnote
为
\usepackage{etoolbox}
\makeatletter
\apptocmd{\TPT@begintabbox}{\let\mTPTprint\@firstofone}{}{}
\apptocmd{\threeparttable}{\let\mTPTprint\relax}{}{}
\newcommand\stnote[1]{\protect\mTPTprint{\textsuperscript{\TPTtagStyle{#1}}}}
\newcommand\mTPTprint[1]{}
\makeatother