siunitx 中列标题的对齐

siunitx 中列标题的对齐

我有下表:

\documentclass{scrartcl}
\usepackage[locale = DE, round-mode = places, round-precision =
4]{siunitx}
\usepackage{booktabs}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{lS*6{S[table-format=-1.8]}}
\toprule
& {Reference} & {FML} & {IFM} & {IFM (NV)} & {PML} & {MM} \\
\midrule
{MSE} & 0.05924657 & 0.07423921 & 0.08774748 & 0.18118911 & 0.13403073
                                                                 & 0.16849250 \\
{Bias} & 0.01030783 & 0.01524758 & -0.06442111 & -0.18893351 & -0.02010527 & 0.03427978 \\
{Std.dev.}  & 0.2433095 & 0.2721779 & 0.2892768 & 0.3816266  & 0.3657325 & 0.40924921 \\
\bottomrule
\end{tabular}
\caption{My table}
\end{table}
\end{document}

但是,列标题的对齐方式不对。我希望它们在列内容上居中。我尝试了各种选项,但都table-alignment无济于事。

答案1

table-format=-1.8小数点后保留了八位小数的位置,但实际上只使用了四位。而且并非所有列都包含负数。

\documentclass{scrartcl}
\usepackage[
  locale = DE,
  round-mode = places,
  round-precision = 4]{siunitx}
\usepackage{booktabs}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{
  l
  *2{S[table-format=1.4]}
  *3{S[table-format=-1.4]}
  S[table-format=1.4]
}
\toprule
& {Reference} & {FML} & {IFM} & {IFM (NV)} & {PML} & {MM} \\
\midrule
{MSE} & 0.05924657 & 0.07423921 & 0.08774748 & 0.18118911 & 0.13403073 & 0.16849250 \\
{Bias} & 0.01030783 & 0.01524758 & -0.06442111 & -0.18893351 & -0.02010527 & 0.03427978 \\
{Std.dev.} & 0.2433095 & 0.2721779 & 0.2892768 & 0.3816266  & 0.3657325 & 0.40924921 \\
\bottomrule
\end{tabular}
\caption{My table}
\end{table}
\end{document}

结果

使用垂直规则可以更轻松地看到标题行单元格的居中:

\setlength{\tabcolsep}{0pt}% no extra space around columns
\begin{tabular}{
  l|
  *2{S[table-format=1.4]|}
  *3{S[table-format=-1.4]|}
  S[table-format=1.4]|
}

结果

相关内容