我该如何修复这个奇怪的间距tabu
?dcolumn
我是否错过了一些最佳实践?
非常感谢!!
\documentclass[letterpaper,11pt,DIV=12]{scrartcl}
\usepackage{booktabs}
\usepackage{tabu}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\begin{document}
\begin{tabu}to \linewidth{l*4{d{2}}}
\toprule
& \multicolumn{2}{c}{Long long long heading A} & \multicolumn{2}{c}{Long long long heading B} \\
\cmidrule(r){2-3} \cmidrule(l){4-5}
& \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)} & \multicolumn{1}{c}{(3)} & \multicolumn{1}{c}{(4)} \\
\midrule
Variable Description & 1.12233 & 1.234 & 0.567 & 0.681 \\
& (0.0123) & (0.01234) & (0.012) & (0.01234) \\
\midrule
$N$ & \multicolumn{1}{c}{123456} & \multicolumn{1}{c}{123456} & \multicolumn{1}{c}{123456} & \multicolumn{1}{c}{123456} \\
\bottomrule
\end{tabu}
\end{document}
答案1
如何使用tabularray
和siunitx
包设置表格的示例:
\documentclass[letterpaper,11pt,DIV=12]{scrartcl}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx, varwidth}
\sisetup{
input-open-uncertainty =,
input-close-uncertainty=,
table-align-text-post=false
}
\begin{document}
\begin{tblr}{colspec={l *{4}{X[c,si={table-format={(}1.5}]}},
measure=vbox
}
\toprule
& \SetCell[c=2]{c}
{{{Long long long heading A}}}
& & \SetCell[c=2]{c}
{{{Long long long heading B}}}
& \\
\cmidrule[lr]{2-3} \cmidrule[l]{4-5}
& {{{(1)}}} & {{{(2)}}} & {{{(3)}}} & {{{(4)}}} \\
\midrule
Variable Description
& 1.12233 & 1.234 & 0.567 & 0.681 \\
& (0.0123) & (0.01234) & (0.012) & (0.01234) \\
\midrule
$N$ & {{{123456}}}
& {{{123456}}}
& {{{123456}}}
& {{{123456}}} \\
\bottomrule
\end{tblr}
\end{document}
答案2
这是一个解决方案,其中 (a) 使用tabular
而不是并且 (b) 用从 到 范围内的替代方案替换tabu
错误的列规范。d{2}
d{2.4}
d{2.6}
\documentclass[letterpaper,11pt,DIV=12]{scrartcl}
\usepackage{booktabs}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}
\noindent
\begin{tabular}{@{} l d{2.5} d{2.6} d{2.4} d{2.6} @{}}
\toprule
& \multicolumn{2}{c}{Heading A} & \multicolumn{2}{c@{}}{Heading B} \\
\cmidrule(lr){2-3} \cmidrule(l){4-5}
& \mc{(1)} & \mc{(2)} & \mc{(3)} & \mc{(4)} \\
\midrule
Variable Description & 1.12233 & 1.234 & 0.567 & 0.681 \\
& (0.0123) & (0.01234) & (0.012) & (0.01234) \\
\midrule
$N$ & \mc{123456} & \mc{123456} & \mc{123456} & \mc{123456} \\
\bottomrule
\end{tabular}
\end{document}