0

I am failing to set up a complex APA table once again.

Actually, I need a table like shown below:

The Monster

My current MWE:

\documentclass[12pt,ngerman]{article}
\usepackage[utf8]{inputenc} 
\usepackage{tabularx} 
\usepackage{booktabs}

\begin{document}

    \begin{table}[!htb]
    \begin{tabularx}{\textwidth}{Xcccccccccccc}  \toprule 
    & Dropout yes/no &  & & & & & & & & & \\
    & No dropout & & & dropout & & & $MW_{dif}$ & $95\% CI for MW_{dif}$  & $t$ & $df$ & $d$ \\ \hline
    & $MW$ & $SD$ & $N$ & $MW$ & $SD$ & $N$ & & & & & \\ 
    General self-efficacy & $10$ & $2$ & $7$ & $29$ & $2$ & $7$ & $8$ & $23.50, 51.00$ & $2.12*$ & $12$ & $0.55$ \\ 
    \bottomrule
    \end{tabularx}
\end{table}

\end{document}

Problem 1: How do I align the upper part (Dropout yes/no) middle to both main areas no dropout and dropout? Vice versa, how do I align the second line to the MW-SD-N?

Problem 2: How do I achieve a line in the main areas which is just including MW/SD and N each?

5
  • 2
    What is the specific problem you're having? Alignment of multi-columns? Line breaks within cells? Without an MWE, we have no way to target our answers. Additionally, the question, without MWE, is of the "do-this-for-me" type, which is not a good fit for the site. Commented Jul 5, 2014 at 15:04
  • @PaulGessler, added the MWE due to your feedback.
    – Jens
    Commented Jul 5, 2014 at 15:43
  • Your MWE has several things that are different from the desired output. It's always best to focus a question on a specific issue as this results in more helpful answers and increased usefulness to future visitors to the site. :-) Commented Jul 5, 2014 at 16:38
  • 1
    Problem 1: use \multicolumn{<num_cols>}{<align>}{<content>} (basic example here, or search TeX.SE for many more). Problem 2: Use \cmidrule(<trim>){<start>-<end>} from the booktabs package. Commented Jul 5, 2014 at 16:57
  • I will give it a try and upload the changed MWE
    – Jens
    Commented Jul 5, 2014 at 17:01

2 Answers 2

1

To centre (roughly) Dropout yes/no between No Dropout and Dropout, I insert a supplementary cell between their respective\multicolumn{3} and use a clap command. It would be perfectly centred if both strings had the same length, so I have to make a minor adjustment, adding some horizontal space.

I also use the makecell package, for line breaking in centred cells, and xcolor for decorative purpose:

\documentclass[10pt,a4paper, ngerman]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[x11names]{xcolor}
\usepackage{colortbl}
\usepackage{ragged2e}
\usepackage[margin = 2.5cm, nomarginpar]{geometry}
\usepackage{mathtools}
\usepackage{tabularx}
\usepackage{makecell}
\renewcommand\cellalign{cb}
\renewcommand{\tabularxcolumn}[1]{>{\RaggedRight\arraybackslash}m{#1}}
\usepackage{booktabs}

\begin{document}

\begin{table}[!htb]
\sffamily\setlength\tabcolsep{7pt}
\begin{tabularx}{\textwidth}{X*{6}{c}@{\qquad}*{6}{c}}
\arrayrulecolor{Tomato3} \toprule\arrayrulecolor{DarkSlateGray4}
\addlinespace
    & & & & \clap{\hspace{0.8em}Dropout yes/no} \\
    & \multicolumn{3}{c}{No dropout} & & \multicolumn{3}{c}{Dropout} & \\
\addlinespace[0.1ex]
\cmidrule(lr){2-4}\cmidrule(lr){6-8}
& MW & SD & N & & MW & SD & N & MW-Dif & \smash{\makecell{95\% CI\\ for MW-Dif}} & t & df & d\\
\cmidrule[\lightrulewidth](lr){1-13}
\addlinespace
General self-efficacy & 10 & 2 & 7 & & 29 & 2 & 7 & 8 & 23.50, 51.00 & 2.12* & 12 & 0.55 \\
\addlinespace
Vocational self-efficacy & 10 & 2 & 7 & & 29 & 2 & 7 & 8 & 23.50, 51.00 & 2.12* & 12 & 0.15 \\
\addlinespace
Other scales & 10 & 2 & 7 & & 29 & 2 & 7 & 8 & 23.50, 51.00 & 2.12* & 12 & 0.11 \\
\addlinespace
\arrayrulecolor{Tomato3} \bottomrule
\end{tabularx}
\end{table}

\end{document} 

enter image description here

1
  • Awesome minor improvements
    – Jens
    Commented Sep 4, 2014 at 0:17
0

This is my solution, based on the input from Paul Gessler in the comments:

\documentclass[12pt,ngerman]{article}
\usepackage[utf8]{inputenc} 
\usepackage{tabularx} 
\usepackage{booktabs}

\begin{document}

\begin{table}[!htb]
    \begin{tabularx}{\textwidth}{Xcccccccccccc} \toprule 
    & \multicolumn{6}{c}{dropout yes/no} \\
    \addlinespace
    & \multicolumn{3}{c}{no dropout} & \multicolumn{3}{c}{dropout} & & & &  \\
    \cmidrule(rl){2-4} \cmidrule(rl){5-7}
    \addlinespace
    & $\mathit{MW}$ & $\mathit{SD}$ & $\mathit{N}$ & $\mathit{MW}$ & $\mathit{SD}$ & $\mathit{N}$ & $\mathit{MW}_{\text{diff}}$ & $95\%$ KI für $\mathit{MW}_{\text{diff}}$ & $t$ & $df$ & $d$ \\  \midrule
    \addlinespace
    General self-efficacy & $10$ & $2$ & $7$ & $29$ & $2$ & $7$ & $8$ & $23.50, 51.00$ & $2.12*$ & $12$ & $0.55$ \\ 
    \bottomrule
    \end{tabularx}
\end{table}

\end{document}
2
  • 1
    Nice work! Now, a few more suggestions. :) 1) Multi-letter math variables (such as $MW$ or $SD$) should be set using $\mathit{MW}$ for better spacing. This will also make the table slightly narrower. 2) Since you're already using booktabs, you can replace \hline with \midrule. 3) Don't set text in math mode; switch back to text mode for proper spacing. Here's an example for your confidence interval cell: $95\%$ CI for $\mathit{MW}_{\text{diff}}$. Note: the \text{} macro is from the amsmath package and is useful for identifiers in math that are not variables. Commented Jul 5, 2014 at 18:14
  • I added your advices to the answer! Thanks a lot!
    – Jens
    Commented Jul 5, 2014 at 18:33

You must log in to answer this question.

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