我对将三部分表格居中感到很沮丧
\documentclass{article}
\usepackage[flushleft]{threeparttable}
\usepackage{booktabs,xcolor,siunitx}
\definecolor{lightgray}{gray}{0.9}
\begin{document}
\begin{table}[!ht]
\caption[Table]{Text\tnote{a}.}\label{table1}
\begin{threeparttable}
\begingroup\setlength{\fboxsep}{0pt}
\colorbox{lightgray}{% for grey shade
\begin{tabular}{l l l}
\hline \hline
\vspace{-0,2cm}&&\\
\textbf{1st Column} & \textbf{2nd Column} & \textbf{3rd Column} \\ \midrule
test\tnote{\textdagger} & & \\
\bottomrule
\end{tabular}
}\endgroup % for grey shade
\begin{tablenotes}
\item[\textdagger] test
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
我尝试过几次将其置于 center-environment 中,也尝试过几次 \centering,但都不起作用。显然,问题出在
\begingroup\setlength{\fboxsep}{0pt}
有人有解决方案吗?我将不胜感激任何帮助。
答案1
这是一个解决方法:
\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage[flushleft]{threeparttablex}%
\usepackage{booktabs,longtable, caption, cellspace, hhline}
\usepackage{siunitx}
\usepackage[table]{xcolor}
\definecolor{lightgray}{gray}{0.9}
\begin{document}
\begin{table}[!ht]
\centering\captionsetup{skip = 4pt}
\setlength{\aboverulesep}{0pt}
\setlength{\belowrulesep}{0pt}
\setlength{\cellspacetoplimit}{5pt}
\setlength{\cellspacebottomlimit}{5pt}
\begin{threeparttable}
\caption[Table]{Text\tnote{a}.}\label{table1}
\rowcolors{1}{lightgray}{lightgray}
\begin{tabular}{Cl l l}
\toprule\arrayrulecolor{lightgray}\midrule[0.5ex]\arrayrulecolor{black} \midrule
\textbf{1st Column} & \textbf{2nd Column} & \textbf{3rd Column} \\ \midrule
test\tnote{\textdagger} & & \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\item[\textdagger] test
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
答案2
这是一个解决方法;colorbox
在里面放一个额外的tabular
。
\documentclass{article}
\usepackage[flushleft]{threeparttable}
\usepackage{booktabs,xcolor,siunitx}
\definecolor{lightgray}{gray}{0.9}
\begin{document}
\begin{table}[!ht]\centering
\caption[Table]{Text\tnote{a}.}\label{table1}
\begin{threeparttable}\begin{tabular}{@{}c@{}}%
\begingroup\setlength{\fboxsep}{0pt}% <-----
\colorbox{lightgray}{% for grey shade
\begin{tabular}{l l l}
\hline \hline
\vspace{-0,2cm}&&\\
\textbf{1st Column} & \textbf{2nd Column} & \textbf{3rd Column} \\ \midrule
test\tnote{\textdagger} & & \\
\bottomrule
\end{tabular}%
}\endgroup % for grey shade
\end{tabular} % <-----
\begin{tablenotes}
\item[\textdagger] test
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
答案3
这是另一种解决方法,使用parbox
封闭tablenotes
环境。
\documentclass{article}
\usepackage{threeparttable}
\usepackage{booktabs,xcolor,siunitx}
\definecolor{lightgray}{gray}{0.9}
\begin{document}
\begin{table}[!ht]
\centering
\caption[Table]{Text\tnote{a}.}\label{table1}
\begin{threeparttable}
\begingroup\setlength{\fboxsep}{0pt}
\colorbox{lightgray}{% for grey shade
\begin{tabular}{l l l}
\hline \hline
\vspace{-0,2cm}&&\\
\textbf{1st Column} & \textbf{2nd Column} & \textbf{3rd Column} \\ \midrule
test\tnote{\textdagger} & & \\
\bottomrule
\end{tabular}
}\endgroup % for grey shade
\parbox{\linewidth}{
\begin{tablenotes}[flushleft]
\item[\textdagger] test
\end{tablenotes}}
\end{threeparttable}
\end{table}
\end{document}