我希望 A1、A3 和 B1 列更像 B3 列,其组外侧面没有任何单元格填充。
我能做到吗?我现在的代码如下:
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table*}\centering
\begin{tabular}{@{}lccccccc@{}}\toprule
& \multicolumn{3}{c}{A} & \phantom{abc}& \multicolumn{3}{c}{B}\\ \cmidrule{2-4} \cmidrule{6-8}
& 1 & 2 & 3 && 1 & 2 & 3\\
\midrule
C & 0.60 & 0.951 & 0.245 & & 1.151 & 1.563 & 0.586 \\
& (0.262) & (0.364) & (0.310) & & (0.620) & (0.905) & (0.696) \\
\midrule
\(N\) & 919629 & 468093 & 451536 & & 186271 & 94771 & 91500 \\
\bottomrule
\end{tabular}
\end{table*}
\end{document}
答案1
除了删除空列之外,我还会使用软件包的工具将数字排列在小数点标记上dcolumn
。
\documentclass{article}
\usepackage{booktabs,dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}
\begin{table}
\centering
\begin{tabular}{@{} l *{6}{d{2.4}} @{}}
\toprule
& \multicolumn{3}{c}{A} & \multicolumn{3}{c@{}}{B}\\ \cmidrule(lr){2-4} \cmidrule(l){5-7}
& \mc{1} & \mc{2} & \mc{3} & \mc{1} & \mc{2} & \mc{3} \\
\midrule
C & 0.60 & 0.951 & 0.245 & 1.151 & 1.563 & 0.586 \\
& (0.262) & (0.364) & (0.310) & (0.620) & (0.905) & (0.696) \\
\midrule
$N$ & \mc{919629} & \mc{468093} & \mc{451536} & \mc{186271} & \mc{94771} & \mc{91500} \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案2
我会写出稍微不同一点的表格:
\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}% added
\begin{document}
\begin{table*}\centering
\begin{tabular}{ l *{6}{S[input-symbols = ( ),
table-space-text-pre={(},
table-space-text-post={)},
table-format=1.3]} }% changed
\toprule
& \multicolumn{3}{c}{A} & \multicolumn{3}{c}{B} \\
\cmidrule(lr){2-4}
\cmidrule(lr){5-7}
& {1} & {2} & {3} & {1} & {2} & {3} \\
\midrule
C & 0.60 & 0.951 & 0.245 & 1.151 & 1.563 & 0.586 \\
& (0.262) & (0.364) & (0.310) & (0.620) & (0.905) & (0.696) \\
\midrule
\(N\) & \num{919629} & \num{468093} & \num{451536} & \num{186271} & \num{94771} & \num{91500} \\ %changed
\bottomrule
\end{tabular}
\end{table*}
\end{document}
或者最终:
\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{table*}\centering
\begin{tabular}{ l *{3}{S[input-symbols = ( ),
table-space-text-pre={(},
table-space-text-post={)},
table-format=1.3]}
c
*{3}{S[input-symbols = ( ),
table-space-text-pre={(},
table-space-text-post={)},
table-format=1.3]} }
\toprule
& \multicolumn{3}{c}{A} && \multicolumn{3}{c}{B} \\
\cmidrule(lr){2-4}
\cmidrule(lr){6-8}
& {1} & {2} & {3} && {1} & {2} & {3} \\
\midrule
C & 0.60 & 0.951 & 0.245 && 1.151 & 1.563 & 0.586 \\
& (0.262) & (0.364) & (0.310) && (0.620) & (0.905) & (0.696) \\
\midrule
\(N\) & \num{919629} & \num{468093} & \num{451536} && \num{186271} & \num{94771} & \num{91500} \\
\bottomrule
\end{tabular}
\end{table*}
\end{document}
(不同之处在于插入的空列会在表格 A 部分和 B 部分之间增加更多空间。)
答案3
(lr)
与 s 结合使用\cmidrule
并删除\phantom{abc}
,它会增加太多空间。
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table*}\centering
\begin{tabular}{@{}lccccccc@{}}
\toprule
& \multicolumn{3}{c}{A} & & \multicolumn{3}{c@{}}{B} \\
\cmidrule(lr){2-4} \cmidrule(l){6-8} & 1 & 2 & 3 & & 1 & 2 & 3 \\ \midrule
C & 0.60 & 0.951 & 0.245 & & 1.151 & 1.563 & 0.586 \\
& (0.262) & (0.364) & (0.310) & & (0.620) & (0.905) & (0.696) \\ \midrule
\(N\) & 919629 & 468093 & 451536 & & 186271 & 94771 & 91500 \\ \bottomrule
\end{tabular}
\end{table*}
\end{document}
答案4
这是通过改变
\begin{tabular}{@{}lccccccc@{}}
到
\begin{tabular}{@{}l@{}ccc@{}c@{}ccc@{}}