\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{caption}
\usepackage{array}
\makeatletter
\g@addto@macro{\endtabular}{\rowfont{}}% Clear row font
\makeatother
\newcommand{\rowfonttype}{}% Current row font
\newcommand{\rowfont}[1]{% Set current row font
\gdef\rowfonttype{#1}#1%
}
\newcolumntype{L}{>{\rowfonttype}l}
\newcolumntype{C}{>{\rowfonttype}c}
\begin{document}
\begin{table}[h]
\begin{threeparttable}
\footnotesize\caption{\footnotesize AAR,CAAR}
\captionsetup{justification=justified, singlelinecheck=true}
\begin{tabular}{C@{\hspace{1cm}}*{6}{p{.125\textwidth}}}
\toprule
& \multicolumn{2}{c}{Phase 1} & \multicolumn{2}{c}{Phase 2} & \multicolumn{2}{c}{Phase 3} \\
\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
Day & AAR & CAAR & AAR & CAAR & AAR & CAAR\\
\midrule
$-10$ & 0.00029 & 0.00029 & $-0.00077$ & $-0.00077$& $-0.00116$ & $-0.00116$ \\
& (0.09) & (0.09) & $(-0.36)$ & $(-0.36)$&$(-0.42)$ &$ (-0.42)$
\bottomrule
\end{tabular}
\begin{tablenotes}[para]
\item[*] $p<0.05$
\item[**] $p<0.01$
\item[***] $p<0.001$
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
你好!我正在尝试将 6 个右列居中,但不知道在这个表达式中将“C”放在哪里:
\begin{tabular}{C@{\hspace{1cm}}*{6}{p{.125\textwidth}}}
我将不胜感激任何帮助!
答案1
添加>{\centering\arraybackslash}
最后 6 个说明符的字体。但是,表格对于文本宽度来说有点太宽了,因此我使用了一个环境,该环境可以根据表格的总宽度tabularx
计算列的宽度。X
\documentclass[12pt]{article}
\usepackage[a4paper, showframe]{geometry}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{caption}
\usepackage{array, tabularx}
\makeatletter
\g@addto@macro{\endtabular}{\rowfont{}}% Clear row font
\makeatother
\newcommand{\rowfonttype}{}% Current row font
\newcommand{\rowfont}[1]{% Set current row font
\gdef\rowfonttype{#1}#1%
}
\newcolumntype{L}{>{\rowfonttype}l}
\newcolumntype{C}{>{\rowfonttype}c}
\begin{document}
\begin{table}[!h]
\begin{threeparttable}
\footnotesize\caption{\footnotesize AAR,CAAR}
\captionsetup{justification=justified, singlelinecheck=true}
\begin{tabularx}{\linewidth}{C@{\hspace{1cm}}*{6}{ >{\centering\arraybackslash}X}}
\toprule
& \multicolumn{2}{c}{Phase 1} & \multicolumn{2}{c}{Phase 2} & \multicolumn{2}{c}{Phase 3} \\
\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
Day & AAR & CAAR & AAR & CAAR & AAR & CAAR\\ \midrule $-10$ & 0.00029 & 0.00029 & $-0.00077$ & $-0.00077$& $-0.00116$ & $-0.00116$ \\
& (0.09) & (0.09) & $(-0.36)$ & $(-0.36)$&$(-0.42)$ &$ (-0.42)$ \\
\bottomrule
\end{tabularx}
\begin{tablenotes}[para]
\smallskip
\item[*] $p<0.05$
\item[**] $p<0.01$
\item[***] $p<0.001$
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}