
를 기반으로이것토론을 통해 다음과 같은 표를 만들었습니다.
\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}{..}
묶는 것이 @Troy가 주석에 제공한 더 나은 솔루션입니다.V1
V2
V3
\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}