
basierend aufDasDiskussion, ich habe die folgende Tabelle erstellt:
\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{caption}
\begin{document}
\begin{table}[ht]
\centering\setlength\extrarowheight{2pt}
\caption{Mean by Year and Group}
\begin{tabular}{@{\extracolsep{4pt}}llc*{2}{S@{\enspace}S@{\enspace}S}}
\toprule
{} & {} & {Sample} & \multicolumn{3}{c}{Median} & \multicolumn{3} {c}{SD}\\
\cmidrule(lr){3-3}
\cmidrule(lr){4-6}
\cmidrule(lr){7-9}
Year & Group & N & V1 & V2 & V3 & V1 & V2 & V3 \\
\midrule
2012 & Control & 2 & 10.052 & 0.294 & 10000.115 & 0.04 & 0.619 & 0.611 \\
& Treat & 2 & 0.511 & 0.083 & 0.123 & 0.573 & 0.541 & 0.734 \\
2016 & Control & 3 & 0.320 & 0.344 & 0.382 & 0.382 & 0.494 & 0.477 \\
& Treat & 3 & 0.378 & 0.296 & 0.123 & 0.386 & 0.668 & 0.732 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
Kann mir jemand helfen V1
, die Spalten V2
und V3
an den Werten in jeder Spalte auszurichten? Ich meine, nach der Verwendung siunitx
des Pakets sind die Spaltentitel am Anfang der Zahl ausgerichtet und nicht in der Mitte.
Antwort1
Eine mögliche Lösung besteht in der Verwendung von \multicolumn{1}{c}{..}
, aber eine bessere Lösung ist das Einschließen von V1
, V2
, und V3
in Klammern, wie @Troy in einem Kommentar angibt.
\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{caption}
\begin{document}
\newcommand{\M}[1]{\multicolumn{1}{c}{#1}}
\begin{table}[ht]
\centering\setlength\extrarowheight{2pt}
\caption{Mean by Year and Group}
\begin{tabular}{@{\extracolsep{4pt}}llc*{2}{S@{\enspace}S@{\enspace}S}}
\toprule
{} & {} & {Sample} & \multicolumn{3}{c}{Median} & \multicolumn{3} {c}{SD}\\
\cmidrule(lr){3-3}
\cmidrule(lr){4-6}
\cmidrule(lr){7-9}
Year & Group & N & \M{V1} & \M{V2} & \M{V3} & \M{V1} & \M{V2} & \M{V3} \\
\midrule
2012 & Control & 2 & 10.052 & 0.294 & 10000.115 & 0.04 & 0.619 & 0.611 \\
& Treat & 2 & 0.511 & 0.083 & 0.123 & 0.573 & 0.541 & 0.734 \\
2016 & Control & 3 & 0.320 & 0.344 & 0.382 & 0.382 & 0.494 & 0.477 \\
& Treat & 3 & 0.378 & 0.296 & 0.123 & 0.386 & 0.668 & 0.732 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}