siunitx:S 列的水平对齐

siunitx:S 列的水平对齐

我正在尝试以 格式呈现平均值和标准差的表格组M (SD)。在 MWE 中,如何“收紧”每个“M(SD)”组的水平对齐?

我希望它们更靠近一些(这样读者就可以看到它们是分组的),但也保持一致的间距(表格目前似乎具有可接受的间距)。

\documentclass[]{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\sisetup{input-symbols = ()}
\begin{table}[h]
  \begin{tabular}{@{}
    l
    S[table-format = 2.1]
    S[table-format = 2.1]
    S[table-format = 2.1]
    S[table-format = 2.1]
    S[table-format = 3.1]
    S[table-format = 2.1]
    S[table-format = 2.1]
    S[table-format = 2.1]
    @{}}
    \toprule
    & \multicolumn{4}{c}{Major Group A} & \multicolumn{4}{c}{Major Group B} \\
    \cmidrule(lr){2-5} \cmidrule(l){6-9}
    & \multicolumn{2}{c}{Subgroup A1} & \multicolumn{2}{c}{Subgroup A2} & \multicolumn{2}{c}{Subgroup B1} & \multicolumn{2}{c}{Subgroup B2} \\
    Test & {M} & {(SD)} & {M} & {(SD)} & {M} & {(SD)} & {M} & {(SD)} \\
    \midrule
    Y-scores & & & & & & & & \\
    \hspace{1em} Y1 & 76.4 & (12.2) & 92.5 & (18.1) & 105.9 & (12.6) & 83.7 & (17.9) \\
    \hspace{1em} Y2 & 38.2 & (9.6) & 47.3 & (18.1) & 51.2 & (7.3) & 38.8 & (9.9) \\
    \hspace{1em} Y3 & 38.3 & (13.8) & 45.2 & (12.5) & 54.8 & (6.1) & 44.9 & (10.6) \\
    \hspace{1em} Y3 &  0.3 & (0.1) & 0.6 & (0.5) & 0.9 & (0.5) & 0.5 & (0.1) \\
    \bottomrule
  \end{tabular}
\end{table}
\end{document}

答案1

像这样:

在此处输入图片描述

\documentclass[]{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\sisetup{input-symbols = ()}
\begin{table}[h]
  \begin{tabular}{
    c
    S[table-format = 2.1]@{}
    S[table-format = 2.1]
    S[table-format = 2.1]@{}
    S[table-format = 2.1]
    S[table-format = 3.1]@{}
    S[table-format = 2.1]
    S[table-format = 2.1]@{}
    S[table-format = 2.1]
    }
    \toprule
    & \multicolumn{4}{c}{Major Group A} & \multicolumn{4}{c}{Major Group B} \\
    \cmidrule(lr){2-5} \cmidrule(l){6-9}
    & \multicolumn{2}{c}{Subgroup A1} & \multicolumn{2}{c}{Subgroup A2} & \multicolumn{2}{c}{Subgroup B1} & \multicolumn{2}{c}{Subgroup B2} \\
    Test & {M} & {(SD)} & {M} & {(SD)} & {M} & {(SD)} & {M} & {(SD)} \\
    \midrule
    Y-scores & & & & & & & & \\
Y1 & 76.4 & (12.2) & 92.5 & (18.1) & 105.9 & (12.6) & 83.7 & (17.9) \\
Y2 & 38.2 & (9.6) & 47.3 & (18.1) & 51.2 & (7.3) & 38.8 & (9.9) \\
Y3 & 38.3 & (13.8) & 45.2 & (12.5) & 54.8 & (6.1) & 44.9 & (10.6) \\
Y3 &  0.3 & (0.1) & 0.6 & (0.5) & 0.9 & (0.5) & 0.5 & (0.1) \\
    \bottomrule
  \end{tabular}
\end{table}
\end{document}

在我看来,下表看起来更好(对于它,您只需要删除上面代码中的一行):

在此处输入图片描述

相关内容