3

I keep getting excessive whitespace between columns in my graphs:

\documentclass{article}

\usepackage{array}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage[flushleft]{threeparttable}
\usepackage[T1]{fontenc}

\newcommand{\M}[1]{\multicolumn{1}{l}{#1}}
\newcommand{\C}[1]{\multicolumn{1}{c}{#1}}

\begin{document}

%summary statistics
\begin{table}[!ht]
    \centering\setlength\extrarowheight{2pt}
    \begin{threeparttable}
        \begin{tabular}{@{\extracolsep{0pt}}cccc*{2}{SSSS}}
            \toprule   
            \C{Behavior} & \C{Sex Ratio} & \multicolumn{3}{c}{Incidence} & \multicolumn{3}{c}{Duration (s)}\\
            \cmidrule(lr){1-1}
            \cmidrule(lr){2-2} 
            \cmidrule(lr){3-5} 
            \cmidrule(lr){6-8} 
            \M{Type} & \C{F:M} & \C{Mean} & \C{${\pm}$} & \C{SEM${^\dagger}$} & \C{Mean} & \C{${\pm}$} & \C{SEM${^\dagger}$} \\ 
            \midrule
            \\[-2.0ex]
            \M{Probing}\\
            \\[-1.8ex]
            \M{A} & 0.84 & \multicolumn{1}{S}{1.3} & ${\pm}$ & 0.13 \ {a} & 260.0 & ${\pm}$ & 12.0 \\ 
            \M{B} & 1.29 & \multicolumn{1}{S}{1.5} & ${\pm}$ & 0.13 \ {a} & 260.0 & ${\pm}$ & 12.0 \\ 
            \M{C} & 1.39 & \multicolumn{1}{S}{1.8} & ${\pm}$ & 0.16 \ {a} & 250.0 & ${\pm}$ & 11.0 \\ 
            \M{D} & 1.44 & \multicolumn{1}{S}{2.8} & ${\pm}$ & 0.38 \ {b} & 270.0 & ${\pm}$ & 6.0 \\
            \bottomrule
        \end{tabular}
    \end{threeparttable}
\end{table}

%ANOVA table
\begin{table}[!htbp]
    \centering\setlength\extrarowheight{2pt}
    \caption{Wald's ${\chi^2}$ tests}
    \label{tab:tbl_1}
    \begin{threeparttable}
        \begin{tabular}{@{\extracolsep{0pt}}ccc*{2}{SSSSSSS}}
            \toprule  
            \M{Behavior${^\dagger}$} & \multicolumn{3}{c}{Incidence} & \multicolumn{3}{c}{Duration}\\ 
            \cmidrule(l){0-0} 
            \cmidrule(l){2-4} 
            \cmidrule(l){5-7}
            \M{Factors} & \C{${\chi^2}$} & \C{df} & \C{Pr \ ${>}$ \ ${\chi^2}$} & \C{${\chi^2}$} & \C{df} & \C{Pr \ ${>}$ \ ${\chi^2}$} \\ 
            \midrule
            \\[-2.0ex]
            \M{Probing} \\
            \\[-2.0ex]
            \M{Variety} & \multicolumn{1}{S}{27.46} & \C{3} & \C{0.000} & 2.51 & \C{3} & \C{0.473} \\ 
            \M{Sex} & \multicolumn{1}{S}{3.24} & \C{1} & \C{0.072} & 0.00 & \multicolumn{1}{c}{1} & \C{0.959} \\ 
            \M{Variety ${\times}$ Sex} & \multicolumn{1}{S}{6.49} & \C{3} & \C{0.090} & 4.74 & \C{3} & \C{0.192} \\
            \bottomrule
        \end{tabular}
    \end{threeparttable}
\end{table}

\end{document}
2

You're misusing the S columns.

\documentclass{article}

\usepackage{array}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage[flushleft]{threeparttable}
\usepackage[T1]{fontenc}

\sisetup{separate-uncertainty}

\newcommand{\M}[1]{\multicolumn{1}{l}{#1}}
\newcommand{\C}[1]{\multicolumn{1}{c}{#1}}

\begin{document}

%summary statistics
\begin{table}[!ht]
\centering
\begin{threeparttable}
\begin{tabular}{
  l
  S[table-format=1.2]
  S[table-format=1.2(2),table-space-text-post={\ a}]
  S[table-format=3.1(3)]
}
\toprule
Behavior &
{Sex Ratio} &
{Incidence} &
{Duration (s)} \\
\cmidrule(lr){1-1}
\cmidrule(lr){2-2}
\cmidrule(lr){3-3}
\cmidrule(lr){4-4}
\C{Type} & {F:M} &
{Mean${}\pm{}$SEM${^\dagger}$} &
{Mean${}\pm{}$SEM${^\dagger}$} \\ 
\midrule
\multicolumn{4}{l}{Probing}\\
A & 0.84 & 1.3 \pm 0.13 \ {a} & 260.0 \pm 12.0 \\ 
B & 1.29 & 1.5 \pm 0.13 \ {a} & 260.0 \pm 12.0 \\ 
C & 1.39 & 1.8 \pm 0.16 \ {a} & 250.0 \pm 11.0 \\ 
D & 1.44 & 2.8 \pm 0.38 \ {b} & 270.0 \pm  6.0 \\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}

%ANOVA table
\begin{table}[!htbp]
\centering

\begin{threeparttable}
\caption{Wald's ${\chi^2}$ tests}
\label{tab:tbl_1}

\begin{tabular}{
  l
  S[table-format=2.2]
  S[table-format=1.0]
  S[table-format=1.3]
  S[table-format=1.2]
  S[table-format=1.0]
  S[table-format=1.3]
}
\toprule  
Behavior${^\dagger}$ & \multicolumn{3}{c}{Incidence} & \multicolumn{3}{c}{Duration}\\ 
\cmidrule(lr){1-1}
\cmidrule(lr){2-4} 
\cmidrule(lr){5-7}
Factors & {${\chi^2}$} & {df} & {$\Pr>\chi^2$} & {${\chi^2}$} & {df} & {$\Pr>\chi^2$} \\ 
\midrule
\multicolumn{7}{l}{Probing} \\
Variety                & 27.46 & 3 & 0.000 & 2.51 & 3 & 0.473 \\ 
Sex                    &  3.24 & 1 & 0.072 & 0.00 & 1 & 0.959 \\ 
Variety${}\times{}$Sex &  6.49 & 3 & 0.090 & 4.74 & 3 & 0.192 \\
\bottomrule
\end{tabular}
\end{threeparttable}

\end{table}

\end{document}

enter image description here

  • Thank worked very well, but I have one last problem. How would I align the decimals in the last column? The 6.0 and 12.0 don't align. I want to match the first Mean \pm SEM part to the second. – fiferworks Apr 14 '18 at 3:47
  • 1
    @fiferworks The specification for the last column (top table) should be S[table-format=3.1(3)]. I don't think there are provisions for aligning the decimal period in the uncertainty part. – egreg Apr 14 '18 at 9:18
2

i assume that your mine problem is the first table. in it i would type your values in three columns with pm in the middle as values with uncertainty:

enter image description here

also the second table has very strange use of the S column type:

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}

\usepackage{array, booktabs}
\usepackage[flushleft]{threeparttable}
%\newcommand{\M}[1]{\multicolumn{1}{l}{#1}} % not used in this mwe
%\newcommand{\C}[1]{\multicolumn{1}{c}{#1}} % not used in this mwe
\usepackage{siunitx}

\begin{document}

%summary statistics
\begin{table}[!ht]
\sisetup{table-number-alignment=center,
         table-figures-decimal=1,
         separate-uncertainty,
         table-figures-uncertainty=1}
    \begin{threeparttable}
\begin{tabular}{c
                S[table-format=1.2]
                S[table-figures-integer=1]
                S[table-figures-integer=3]
                }
    \toprule
Behavior    & {Sex Ratio}
                & {Incidence}       & {Duration (s)}                    \\
    \cmidrule(lr){1-1}
    \cmidrule(lr){2-2}
    \cmidrule(lr){3-3}
    \cmidrule(lr){4-4}
Type    & F:M   & {Mean $\pm$ SEM\tnote{$\dagger$}}
                                    & {Mean $\pm$ SEM\tnote{$\dagger$}} \\
    \midrule
Probing &       &                   &                                   \\
A       & 0.84  &  1.3(13)\tnote{a} & 260.0(12)                         \\
B       & 1.29  &  1.5(13)\tnote{a} & 260.0(12)   \\
C       & 1.39  &  1.8(16)\tnote{a} & 250.0(11)   \\
D       & 1.44  &  2.8(38)\tnote{b} & 270.0(6)    \\
            \bottomrule
        \end{tabular}
    \end{threeparttable}
\end{table}

% ANOVA table
    \begin{table}[!htbp]
    \caption{Wald's ${\chi^2}$ tests}
    \label{tab:tbl_1}
\begin{tabular}{l
           *{2}{S[table-format=2.1]
                S[table-format=1.0]
                S[table-format=1.3]}
                }
        \toprule
Behavior${^\dagger}$    
        & \multicolumn{3}{c}{Incidence} 
                & \multicolumn{3}{c}{Duration}  \\
    \cmidrule(l){0-0}
    \cmidrule(l){2-4}
    \cmidrule(l){5-7}
Factors & {$\chi^2$}    & {df}  & {$\mathrm{Pr}>\chi^2$} 
        & {$\chi^2$}    & {df}  & {$\mathrm{Pr}>\chi^2$}    \\
    \midrule
Probing &               &       &       &       &       &                   \\
Variety & 27.46         & 3     & 0.000 & 2.51  & 3     & 0.473             \\
Sex     &  3.24         & 1     & 0.072 & 0.00  & 1     & 0.959             \\
Variety ${\times}$ Sex 
        & 6.49          & 3     & 0.090 & 4.74 & 3      & 0.192             \\
    \bottomrule
\end{tabular}
    \end{table}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.