1

I am trying to present tabular groups of means and standard deviations in the format M (SD). In the MWE how can I "tighten up" the horizontal alignment of each "M (SD)" group?

I would like them to be closer together (so the reader can see that they are grouped), but also maintain a consistent spacing (which the table seems to currently have acceptably).

\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 Answer 1

2

Like this:

enter image description here

\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}

To my opinion the following table looks better (for it you only need to erase one row in above code):

enter image description here

4
  • Thank you, that's great. In my source document I'm actually using the Linux Libertine font, and it seems like the brackets around the standard deviation value are using a different font, do you know how to change that at all?
    – drgibbon
    Feb 6, 2016 at 13:06
  • I haven't this font, so I cannot test, how to use it in sinutx. It use math fonts, if this help.
    – Zarko
    Feb 6, 2016 at 13:35
  • Ok no problem. By the way, is there an automated StackExchange way of getting those table images into the answer, or did you just take a screenshot and attach it?
    – drgibbon
    Feb 6, 2016 at 23:38
  • I use simple technique for uploade of images: generate picture by code, show it on screen and than cut a interesting part with Windows "Sniping tool", store in one directory as "capture.png". For upload in SE I click on icon with picture, which enable transfer of stored image to my answer (question).
    – Zarko
    Feb 6, 2016 at 23:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .