在表格中的单词下方添加一条线

在表格中的单词下方添加一条线

我试图将第一行中最正确的单词“MS-TVTP”放在其下方单词“MS-TVTP-DRA”的中间(类似于将第一行中的其他两个单词放在其下方单词的中间)。这是代码

\documentclass[11pt,a4paper]{article}
\usepackage{amssymb, amsmath, bm}
\usepackage[flushleft]{threeparttable}
\usepackage{float, booktabs, makecell, caption, tabularx}
\usepackage{siunitx}

\begin{document}

\begin{landscape}

\begin{table}[htb!]
\centering
\caption{\textbf{Diebold-Mariano statistics - regime-switching models}}
\label{table:diebold_mariano_msdns}
\begin{threeparttable}

\begin{tabular}{@{} l *{7}{S[table-align-text-post=false]}}
\toprule
\specialrule{0.4pt}{\aboverulesep}{0pt}
& \multicolumn{3}{c}{MS-DNS} & \multicolumn{2}{c}{MS-DRA} & \multicolumn{2}{c@{}}{MS-TVTP} \\ 
\cmidrule(r){2-4} \cmidrule(l){5-6} \cmidrule(l){7-8}
\hline 
Maturity (months) 
& \multicolumn{1}{c}{MS-DRA} 
& \multicolumn{1}{c}{MS-TVTP}
& \multicolumn{1}{c}{MS-DRA-TVTP}
& \multicolumn{1}{c}{MS-TVTP}
& \multicolumn{1}{c}{MS-DRA-TVTP}
& \multicolumn{1}{c@{}}{MS-DRA-TVTP} \\ 
\midrule
Panel (A): 1-month horizon \\ 
3   & $\bm{0.96}$ & $\bm{1.14}$ & $\bm{0.91}$   \\
6   & $\bm{1.14}$ & $\bm{1.31}$ & $\bm{1.07}$   \\
12  & $\bm{0.95}$ & $\bm{1.01}$ & $\bm{0.89}$   \\
24  & $\bm{0.55}$ & $\bm{0.37}$ & $\bm{0.58}$   \\
36  & $\bm{0.49}$ & $\bm{0.43}$ & $\bm{0.41}$   \\
60  & $\bm{0.93}$ & $\bm{0.59}$ & $\bm{0.82}$   \\
84  & $\bm{0.82}$ & $\bm{0.81}$ & $\bm{0.72}$   \\
120 & $\bm{0.73}$ & $\bm{0.83}$ & $\bm{0.66}$   \\
\addlinespace
Panel (B): 6-month horizon \\ 
3   & $\bm{0.94}$ & $\bm{1.09}$ & $\bm{0.94}$  \\
6   & $\bm{0.95}$ & $\bm{1.08}$ & $\bm{0.93}$  \\
12  & $\bm{0.93}$ & $\bm{1.04}$ & $\bm{0.91}$  \\
24  & -0.01       & $\bm{1.08}$ & $\bm{0.95}$  \\
36  & $\bm{0.64}$ & $\bm{0.64}$ & $\bm{0.45}$  \\
60  & $\bm{0.64}$ & $\bm{0.91}$ & $\bm{0.64}$  \\
84  & $\bm{0.65}$ & $\bm{1.02}$ & $\bm{0.52}$  \\
120 & $\bm{0.59}$ & $\bm{1.76}$ & $\bm{0.48}$  \\
\addlinespace
Panel (C): 12-month horizon \\ 
3   & $\bm{1.02}$ & $\bm{1.13}$ & $\bm{1.32}$ \\
6   & $\bm{0.76}$ & $\bm{0.90}$ & $\bm{1.01}$ \\
12  & $\bm{1.01}$ & $\bm{1.24}$ & $\bm{1.22}$ \\
24  & $\bm{0.27}$ & $\bm{0.37}$ & $\bm{0.29}$ \\
36  & $\bm{0.33}$ & $\bm{0.49}$ & $\bm{0.43}$ \\
60  & $\bm{0.51}$ & $\bm{0.80}$ & $\bm{0.66}$ \\
84  & $\bm{0.56}$ & $\bm{0.95}$ & $\bm{0.63}$ \\
120 & $\bm{0.36}$ & $\bm{0.82}$ & $\bm{0.39}$ \\
\bottomrule
\end{tabular}

\smallskip
\begin{tablenotes}\footnotesize
 \item Note: This table reports statistics of the Diebold-Mariano (DM) test for equal forecast accuracy between the macro regime-switching models and the MS-DNS model. Under the null hypothesis, the forecasts of both models have the same mean squared error. A positive DM-statistic is highlighted in bold and indicates that the model constructs better forecasts than the random walk. An asterisk (*) denotes significance relative to the asymptotic null distribution at the five percent level.
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{landscape}

\end{document} 

先感谢您。

答案1

这是一个使用longtablemakecell (以简化一些代码)和的解决方案threeparttablex。请注意,后一个包的语法与 的语法略有不同threeparttable。此外,我定义了一个B列类型,基于S此可以省去必须在每个单元格中输入 $\bm{number}$ 的麻烦。

\documentclass[11pt, a4paper]{article}
\usepackage{geometry}
\usepackage{calc}
\usepackage{amssymb, mathtools, bm}
\usepackage[flushleft]{threeparttablex}
\usepackage{float, booktabs, makecell, caption, tabularx, xltabular}
\usepackage{siunitx}
\newcolumntype{B}{>{\bfseries}S}
\usepackage{lscape}
% \newlength\Swd
% \settowidth{\Swd}{MS-DRA-TVTP}

\begin{document}

\begin{landscape}
\begin{ThreePartTable}
\sisetup{table-align-text-post=false, detect-weight, table-number-alignment=center}
\centering%
\captionsetup{font=bf, skip=6pt}
\renewcommand{\cellset}{\mdseries}
%%%%%%%%%%%%%%%%%%%%%%
\begin{TableNotes}[online]\footnotesize
 \item[\emph{Note}:]This table reports statistics of the Diebold-Mariano (DM) test for equal forecast accuracy between the macro regime-switching models and the MS-DNS model. Under the null hypothesis, the forecasts of both models have the same mean squared error. A positive DM-statistic is highlighted in bold and indicates that the model constructs better forecasts than the random walk. An asterisk (*) denotes significance relative to the asymptotic null distribution at the five percent level.
\end{TableNotes}
%%%%%%%%%%%%%%%%%%%%%%
\begin{longtable} {@{} l*{6}{B}@{}}%
\caption{Diebold-Mariano statistics -- regime-switching models }
\label{table:diebold_mariano_msdns} \\
\toprule
\specialrule{0.4pt}{\aboverulesep}{3pt}
& \multicolumn{3}{c}{MS-DNS} & \multicolumn{2}{c}{MS-DRA} &{\makecell{MS-TVTP}} \\%
\cmidrule(r){2-4} \cmidrule(l){5-6} \cmidrule(l){7-7}
Maturity (months)
&{ \makecell{MS-DRA}}
& {\makecell{MS-TVTP}}
& {\makecell{MS-DRA-TVTP}}
& {\makecell{MS-TVTP}}
& {\makecell{MS-DRA-TVTP}}
& {\makecell{MS-DRA-TVTP}} \\
\midrule
\endfirsthead
%
noalign{\addtocounter{table}{-1}}
\caption[]{Diebold-Mariano statistics -- regime-switching models \enspace\mdseries (\emph{Continued})} \\
\midrule
& \multicolumn{3}{c}{MS-DNS} & \multicolumn{2}{c}{MS-DRA} &{\makecell{MS-TVTP}} \\%
\cmidrule(r){2-4} \cmidrule(l){5-6} \cmidrule(l){7-7}
Maturity (months)
&{ \makecell{MS-DRA}}
& {\makecell{MS-TVTP}}
& {\makecell{MS-DRA-TVTP}}
& {\makecell{MS-TVTP}}
& {\makecell{MS-DRA-TVTP}}
& {\makecell{MS-DRA-TVTP}} \\
\midrule
\endhead
%
\midrule
\multicolumn{7}{r@{}}{\footnotesize \textit{To be continued}}
\endfoot
%
\bottomrule
\addlinespace
\insertTableNotes
\endlastfoot
%%%%%%%%%%%%%%%%%%%%%%%%%%
\addlinespace
\rlap{Panel (A): 1-month horizon} \\
3 & 0.96 & 1.14 & 0.91 & 0.96 & 1.14\\
6 & 1.14 & 1.31 & 1.07 \\
12 & 0.95 & 1.01 & 0.89 \\
24 & 0.55 & 0.37 & 0.58 \\
36 & 0.49 & 0.43 & 0.41 \\
60 & 0.93 & 0.59 & 0.82 \\
84 & 0.82 & 0.81 & 0.72 \\
120 & 0.73 & 0.83 & 0.66 \\
\addlinespace
\rlap{Panel (B): 6-month horizon} \\
3 & 0.94 & 1.09 & 0.94 \\
6 & 0.95 & 1.08 & 0.93 \\
12 & 0.93 & 1.04 & 0.91 \\
24 & -0.01 & 1.08 & 0.95 \\
36 & 0.64 & 0.64 & 0.45 \\
60 & 0.64 & 0.91 & 0.64 \\
84 & 0.65 & 1.02 & 0.52 \\
120 & 0.59 & 1.76 & 0.48 \\
\addlinespace
\rlap{Panel (C): 12-month horizon} \\
3 & 1.02 & 1.13 & 1.32 \\
6 & 0.76 & 0.90 & 1.01 \\
12 & 1.01 & 1.24 & 1.22 \\
24 & 0.27 & 0.37 & 0.29 \\
36 & 0.33 & 0.49 & 0.43 \\
60 & 0.51 & 0.80 & 0.66 \\
84 & 0.56 & 0.95 & 0.63 \\
120 & 0.36 & 0.82 & 0.39
\end{longtable}
\end{ThreePartTable}
\end{landscape}

\end{document} 

在此处输入图片描述

答案2

如同伯纳德答案。差异(新命令、、\sisetup使用\multrowthreeparttablex……)在代码中用 表示% <---。请注意,在未使用 合并的单元格的每一行中,\multicolumn与定义的列数应具有相同数量的“与”符号。

\documentclass[11pt, a4paper]{article}
\usepackage{geometry}
\usepackage{amssymb, mathtools, bm}
\usepackage[referable]{threeparttablex} % <---
\usepackage{booktabs, 
            longtable, 
            multirow}                   % <---
\newlength\Swd

\usepackage[font=bf, skip=6pt]{caption} % <---
\usepackage{siunitx}
\usepackage{pdflscape}

\usepackage{xparse}                     % <---
\NewExpandableDocumentCommand\mcc{O{1}m}% <---
    {\multicolumn{#1}{c}{#2}}
\NewExpandableDocumentCommand\mcl{O{1}m}% <---
    {\multicolumn{#1}{l}{#2}}

\begin{document}

\begin{landscape}
\begin{ThreePartTable}
\captionof{figure}{Diebold-Mariano statistics -- regime-switching models}
\label{table:diebold_mariano_msdns}                             
%
    \sisetup{detect-weight, 
             table-space-text-post=*,       % <---
             round-mode=places,             % <---
             round-precision=2,             % <---
             }
    \centering%
    \settowidth{\Swd}{Maturity}
%%%%%%%%%%%%%%%%%%%%%%
\begin{TableNotes}[flushleft]\footnotesize                          % <---      
\note                                                               % <---
This table reports statistics of the Diebold-Mariano (DM) test for equal forecast accuracy between the macro regime-switching models and the MS-DNS model. Under the null hypothesis, the forecasts of both models have the same mean squared error. A positive DM-statistic is highlighted in bold and indicates that the model constructs better forecasts than the random walk. An asterisk (*) denotes significance relative to the asymptotic null distribution at the five percent level.
\end{TableNotes}
%%%%%%%%%%%%%%%%%%%%%%
\begin{longtable}{S[table-format=3.0]                               % <---
 *{6}{>{\bfseries}S[round-integer-to-decimal=true]}                 % <---
                 }        
    \toprule
{\multirow{2.3}{\Swd}{Maturity (months)}}                           % <---
    & \mcc[3]{MS-DNS}   & \mcc[2]{MS-DRA}   & \mcc{ MS-TVTP}    \\  % <--- 
    \cmidrule(l){2-4} \cmidrule(l){5-6} \cmidrule(l){7-7}
    & \mcc{MS-DRA}      & \mcc{MS-TVTP}     & \mcc{MS-DRA-TVTP}     % <---
    & \mcc{MS-TVTP}     & \mcc{MS-DRA-TVTP} & \mcc{MS-DRA-TVTP} \\  % <---
    \midrule
\endfirsthead
%
\caption[]{ Diebold-Mariano statistics -- regime-switching models
            \enspace\mdseries (\emph{Continued})}               \\
    \toprule
{\multirow{2.3}{\Swd}{Maturity (months)}}                           % <---
    & \mcc[3]{MS-DNS}   & \mcc[2]{MS-DRA}   & \mcc{MS-TVTP}     \\  % <---
    \cmidrule(l){2-4} \cmidrule(l){5-6} \cmidrule(l){7-7}
    & \mcc{MS-DRA}      & \mcc{MS-TVTP}     & \mcc{MS-DRA-TVTP}     % <---
    & \mcc{MS-TVTP}     & \mcc{MS-DRA-TVTP} & \mcc{MS-DRA-TVTP} \\  % <---
    \midrule
\endhead
%
    \midrule
    \multicolumn{7}{r@{}}{\footnotesize\textit{To be continued}}
\endfoot
%
    \midrule[\heavyrulewidth]
    \insertTableNotes
\endlastfoot
%%%%%%%%%%%%%%%%%%%%%%%%%%
\mcl[7]{Panel (A): 1-month horizon}         \\   % <---
3   &  0.96 & 1.14 & 0.91 & 0.96 & 1.14 & 1.23456\tnote{*}  \\
6   &  1.14 & 1.31 & 1.07 &      &      &   \\
12  &  0.95 & 1.01 & 0.89 &      &      &   \\
24  &  0.55 & 0.37 & 0.58 &      &      &   \\
36  &  0.49 & 0.43 & 0.41 &      &      &   \\
60  &  0.93 & 0.59 & 0.82 &      &      &   \\
84  &  0.82 & 0.81 & 0.72 &      &      &   \\
120 &  0.73 & 0.83 & 0.66 &      &      &   \\
\addlinespace
\mcl[7]{Panel (B): 6-month horizon}         \\
3   &  0.94 & 1.09 & 0.94 &      &      &   \\
6   &  0.95 & 1.08 & 0.93 &      &      &   \\
12  &  0.93 & 1.04 & 0.91 &      &      &   \\
24  & -0.01 & 1.08 & 0.95 &      &      &   \\
36  &  0.64 & 0.64 & 0.45 &      &      &   \\
60  &  0.64 & 0.91 & 0.64 &      &      &   \\
84  &  0.65 & 1.02 & 0.52 &      &      &   \\
120 &  0.59 & 1.76 & 0.48 &      &      &   \\
\addlinespace
\mcl[7]{Panel (C): 12-month horizon}        \\
3   &  1.02 & 1.13 & 1.32 &      &      &   \\
6   &  0.76 & 0.90 & 1.01 &      &      &   \\
12  &  1.01 & 1.24 & 1.22 &      &      &   \\
24  &  0.27 & 0.37 & 0.29 &      &      &   \\
36  &  0.33 & 0.49 & 0.43 &      &      &   \\
60  &  0.51 & 0.80 & 0.66 &      &      &   \\
84  &  0.56 & 0.95 & 0.63 &      &      &   \\
120 &  0.36 & 0.82 & 0.39 &      &      &   \\
\end{longtable}
\end{ThreePartTable}
\end{landscape}

\end{document}

在此处输入图片描述

在此处输入图片描述

相关内容