这有什么问题?我需要“DFM”和“BM”一次位于“2005-2014”下方,一次位于“2015-2020”下方。我还想在“DFM”和“BM”两列下方插入一条较短的水平线,同样一次位于“2005-2014”下方,一次位于“2015-2020”下方。
有人能帮助我做到这一点吗?
我在下面发布了最近的一次尝试:
\documentclass[a4paper,11pt]{article}
\usepackage{graphicx}% Package necessary to put graphics in your TeX document
\captionsetup[table]{font={stretch=1}} %% change 1.2 as you like
\captionsetup[figure]{font={stretch=1}} %% change 1.2 as you like
\usepackage{threeparttable}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{etoolbox}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{float}
\begin{document}
\begin{table}[H]
\captionsetup{font=large, labelfont=bf}
\centering
\setlength{\tabcolsep}{10pt}
\begin{threeparttable}
\caption{Forecast Evaluation}
\begin{tabular}{cccc}
\toprule
\textbf{Horizon} & \textbf{2005-2014} & \textbf{Horizon} & \textbf{2015-2020} \tabularnewline
\midrule
\multicolumn{1}{c}{DFM} & \multicolumn{1}{c}{BM} \\
\cline{2-3}
1 & Daily & 1 & No delay \tabularnewline
\addlinespace
2 & Daily & 4 & No delay \tabularnewline
\addlinespace
3 & Daily & 6 & No delay \tabularnewline
\addlinespace
4 & Daily & 8 & No delay \tabularnewline
\bottomrule
\end{tabular}
\begin{tablenotes}[flushleft]
\small
\item\hskip -\fontdimen2\font\textit{Note}: Ciao
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
非常感谢你的帮助!
答案1
\documentclass[a4paper,11pt]{article}
\usepackage{graphicx}% Package necessary to put graphics in your TeX document
% \captionsetup[table]{font={stretch=1}} %% change 1.2 as you like
% \captionsetup[figure]{font={stretch=1}} %% change 1.2 as you like
\usepackage{threeparttable}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{etoolbox}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{float}
\begin{document}
\begin{table}[H]
% \captionsetup{font=large, labelfont=bf}
\centering
\setlength{\tabcolsep}{10pt}
\begin{threeparttable}
\caption{Forecast Evaluation}
\begin{tabular}{cccccc}
\toprule
\textbf{Horizon}& \multicolumn{2}{c}{\textbf{2005-2014}} & \textbf{Horizon} & \multicolumn{2}{c}{\textbf{2015-2020}} \\
\midrule
&\multicolumn{1}{c}{DFM} & \multicolumn{1}{c}{BM} & &\multicolumn{1}{c}{DFM} & \multicolumn{1}{c}{BM}\\
\cline{2-3}\cline{5-6}
1 & Daily & 1 & No delay \tabularnewline
\addlinespace
2 & Daily & 4 & No delay \tabularnewline
\addlinespace
3 & Daily & 6 & No delay \tabularnewline
\addlinespace
4 & Daily & 8 & No delay \tabularnewline
\bottomrule
\end{tabular}
\begin{tablenotes}[flushleft]
\small
\item\hskip -\fontdimen2\font\textit{Note}: Ciao
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
答案2
我给你提供三个选项。第一个是我认为你要求的,第二个是我认为你试图做的(因为有 s \multicolumn
)。最后,第三个是看起来更好的(对我来说,我不知道表格数据的含义)。
\documentclass[a4paper,11pt]{article}
\usepackage{booktabs}
\usepackage{threeparttable}
% only to put all the tables in the same page:
\usepackage{geometry}
\geometry{top=15mm,bottom=15mm}
\begin{document}
\begin{table}[h]\centering
\setlength{\tabcolsep}{10pt}
\begin{threeparttable}
\caption{Forecast Evaluation}
\begin{tabular}{cccc}
\toprule
\textbf{Horizon} & \textbf{2005--2014} & \textbf{Horizon} & \textbf{2015--2020} \tabularnewline
\midrule
& DFM & & BM\\
\cmidrule{2-2}\cmidrule{4-4}
1 & Daily & 1 & No delay\tabularnewline\addlinespace
2 & Daily & 4 & No delay\tabularnewline\addlinespace
3 & Daily & 6 & No delay\tabularnewline\addlinespace
4 & Daily & 8 & No delay\tabularnewline
\bottomrule
\end{tabular}
\begin{tablenotes}[flushleft]
\item\small\hskip -\fontdimen2\font\textit{Note}: Ciao
\end{tablenotes}
\end{threeparttable}
\end{table}
\begin{table}[h]\centering
\setlength{\tabcolsep}{10pt}
\begin{threeparttable}
\caption{Forecast Evaluation}
\begin{tabular}{cccc}
\toprule
\textbf{Horizon} & \textbf{2005--2014} & \textbf{Horizon} & \textbf{2015--2020}\tabularnewline
\midrule
\multicolumn{2}{c}{DFM} & \multicolumn{2}{c}{BM}\\
\cmidrule(r){1-2}\cmidrule(l){3-4}
1 & Daily & 1 & No delay\tabularnewline\addlinespace
2 & Daily & 4 & No delay\tabularnewline\addlinespace
3 & Daily & 6 & No delay\tabularnewline\addlinespace
4 & Daily & 8 & No delay\tabularnewline
\bottomrule
\end{tabular}
\begin{tablenotes}[flushleft]
\item\small\hskip -\fontdimen2\font\textit{Note}: Ciao
\end{tablenotes}
\end{threeparttable}
\end{table}
\begin{table}[h]\centering
\setlength{\tabcolsep}{10pt}
\begin{threeparttable}
\caption{Forecast Evaluation}
\begin{tabular}{cccc}
\toprule
\multicolumn{2}{c}{\bfseries DFM} & \multicolumn{2}{c}{\bfseries BM}\\
\cmidrule(r){1-2}\cmidrule(l){3-4}
Horizon & 2005--2014 & Horizon & 2015--2020\tabularnewline
\midrule
1 & Daily & 1 & No delay\tabularnewline\addlinespace
2 & Daily & 4 & No delay\tabularnewline\addlinespace
3 & Daily & 6 & No delay\tabularnewline\addlinespace
4 & Daily & 8 & No delay\tabularnewline
\bottomrule
\end{tabular}
\begin{tablenotes}[flushleft]
\item\small\hskip -\fontdimen2\font\textit{Note}: Ciao
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}