我再次无法设置复杂的 APA 表。
实际上,我需要如下所示的表格:
我目前的 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}
问题 1:如何将上部(Dropout 是/否)中间部分与两个主要区域对齐,无 dropout 和 dropout?反之亦然,如何将第二行与 MW-SD-N 对齐?
问题 2:如何在主要区域内实现一条仅包含 MW/SD 和 N 的线?
答案1
为了将和大致居中Dropout yes/no
,我在它们各自的 之间插入一个补充单元格并使用命令。如果两个字符串的长度相同,它将完全居中,因此我必须进行微小调整,添加一些水平空间。No Dropout
Dropout
\multicolumn{3}
clap
我还使用该makecell
包,用于在中心单元格中换行,以及xcolor
用于装饰目的:
\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}
答案2
这是我的解决方案,基于 Paul Gessler 在评论中的意见:
\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}