
に基づくこれ議論のために、次の表を作成しました。
\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}
V1
、列V2
を各列の値に揃えるのを手伝ってくれる人はいませんかV3
? つまり、siunitx
パッケージを使用した後、列のタイトルは数字の中央ではなく先頭に揃えられます。
答え1
可能な解決策としては を使用することです\multicolumn{1}{c}{..}
が、 、 、 を中括弧で囲む方が、V1
@ V2
TroyV3
のコメントで示されているより良い解決策です。
\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}