你好,我正在尝试创建这个表,但我无法修复标题,这是我的建议以及我想要的输出
我的建议:
\documentclass{article}
\usepackage{geometry}
\usepackage{rotating}
\usepackage{booktabs, makecell}
\usepackage[referable]{threeparttablex}
\usepackage{siunitx}
\usepackage[skip=1ex]{caption}
\NewExpandableDocumentCommand\mcc{O{1}m}
{\multicolumn{#1}{>{\bfseries}c}{#2}}
\begin{document}
\begin{table}[h!]
\centering
\begin{threeparttable}
\caption{Individual ARDL model forecasting results}
\label{tab1}
\begin{tabular}{@{} >{\itshape}l
*{8}{S[table-format=3.2]}
}
\toprule
\multirow{2.1}{*}{Predictor}
& \mcc[4]{1995:04-2005:03 out-of-sample period} & \mcc[4]{1985:04–2005:03 out-of-sample period} \\
\cmidrule(l){2-5} \cmidrule(l){6-9}
& \mcc{h=1} & \mcc{h=3} & \mcc{h=6} & \mcc{h=12}
& \mcc{h=1} & \mcc{h=3} & \mcc{h=6} & \mcc{h=12} \\
\midrule
AR benchmark& 9.13& 2.99& 1.79& 1.14& 8.75& 2.77& 1.68& 1.19\\
Weekly manufacturing hours& 1.00& 1.00& 1.00& 1.10& 1.00& 1.00& 1.00& 1.09\\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}
我的输出:
答案1
为了在较长的列标题中添加手动换行符,我使用了您已加载的包\thead
中的命令。此外,我还更正了所有列的错误选项,并对其中一个命令做了一些小改动,以增加相邻 cmidrules 之间的间隙。但是,我没有解决第一列和列标题中的斜体/粗体文本,这是当前输出和预期输出图像之间的另一个差异。makecell
table-format
\cmidrule
\documentclass{article}
\usepackage{geometry}
\usepackage{rotating}
\usepackage{booktabs, makecell}
\usepackage[referable]{threeparttablex}
\usepackage{siunitx}
\usepackage[skip=1ex]{caption}
\NewExpandableDocumentCommand\mcc{O{1}m}
{\multicolumn{#1}{>{\bfseries}c}{#2}}
\usepackage{multirow}
\renewcommand{\theadfont}{\normalsize} %<------ added
\begin{document}
\begin{table}[h!]
\centering
\begin{threeparttable}
\caption{Individual ARDL model forecasting results}
\label{tab1}
\begin{tabular}{@{} >{\itshape}l
*{8}{S[table-format=1.2]}% <----- corrected wrong table-format option
}
\toprule
\multirow{2.1}{*}{Predictor}
& \mcc[4]{\thead{1995:04-2005:03\\ out-of-sample period}}
& \mcc[4]{\thead{1985:04–2005:03\\ out-of-sample period}} \\ % <------ added thead command and manual line break
\cmidrule(r){2-5} \cmidrule(l){6-9} % first cmidrule: replaced (l) with (r) to increase gap
& \mcc{h=1} & \mcc{h=3} & \mcc{h=6} & \mcc{h=12}
& \mcc{h=1} & \mcc{h=3} & \mcc{h=6} & \mcc{h=12} \\
\midrule
AR benchmark& 9.13& 2.99& 1.79& 1.14& 8.75& 2.77& 1.68& 1.19\\
Weekly manufacturing hours& 1.00& 1.00& 1.00& 1.10& 1.00& 1.00& 1.00& 1.09\\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}