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

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

我似乎无法修复这个小问题,即单词“MS-DNS”下方的行与单词左侧对齐,而不是与单词右侧对齐。这是 LaTeX 代码

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

\begin{document}

\begin{table}[htb!]
\caption{\textbf{Filtered errors MS-DNS model and extensions with macro 
factors}}
 \label{table:filtered_errors_macro}
 \centering
 \begin{threeparttable}
\renewcommand{\TPTminimum}{\linewidth}
\makebox[\linewidth]{%
\begin{tabular}{@{} l *{8}{S[table-format=1.3]} @{}}
\toprule 
\hline 
& \multicolumn{2}{c}{MS-DNS} 
& \multicolumn{2}{c}{MS-DRA} 
& \multicolumn{2}{c}{MS-TVTP}
& \multicolumn{2}{c@{}}{MS-DNS-X} \\ 
 \cmidrule(l){4-5} \cmidrule(l){6-7} \cmidrule(l){8-9} \cmidrule(l){10-11}
Maturity & {Mean} & {Std.\ dev.} 
         & {Mean} & {Std.\ dev.}
     & {Mean} & {Std.\ dev.}
     & {Mean} & {Std.\ dev.} \\ 
\midrule
3      & -0.066 & 0.063 & -0.070 & 0.345 & -0.139 & 0.330  & -0.229 & 1.608 \\
6      &  0.027 & 0.047 &  0.003 & 0.325 & -0.049 & 0.257  & -0.327 & 3.440 \\
12     & 0.076  & 0.072 &  0.037 & 0.334 & 0.014  & 0.226  & -0.556 & 6.140 \\
24     & 0.025  & 0.025 & -0.002 & 0.330 & 0.020  & 0.228  & -0.898 & 8.853 \\
36     & -0.034 & 0.037 & -0.038 & 0.324 & 0.012  & 0.227  & -1.059 & 9.544 \\
60     & -0.074 & 0.055 & -0.068 & 0.314 & 0.000  & 0.225  & -1.107 & 8.643 \\
84     & -0.032 & 0.026 & -0.050 & 0.304 & 0.010  & 0.222  & -1.013 & 7.118 \\
120    & 0.079  & 0.057 & 0.009 & 0.305 & 0.044  & 0.229  & -0.834 & 5.276\\
\addlinespace
Mean   & 0.000  & 0.048 & -0.022 & 0.323 & -0.011 & 0.243  & -0.753 & 6.328 \\
Median & -0.004 & 0.051 & -0.020 & 0.324 & 0.011  & 0.228  & -0.866 & 6.629 \\
Lower  &        &       &  5     &  0    & 5      & 0         &  0     & 0     
\\
\bottomrule
\end{tabular}
}
\smallskip

\begin{tablenotes}[flushleft]\footnotesize\smallskip
 \item Note: This table reports filtered errors from the MS-DNS model and its 
extensions with macro factors. The filtered errors are defined as the residuals 
of the measurement equation and are formed by taking the difference of the 
observed yield and its filtered estimate obtained by the Kim filter. For each 
maturity, I present the mean and standard deviation (\textit{Std. dev.}). 
Moreover, I show the mean, median and number of maturities for which the mean 
of the extended macro model is lower than the mean of the MS-DNS model in 
absolute terms (\textit{Lower}).
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document} 

LaTeX 代码的输出希望能清楚地表明问题是什么:

在此处输入图片描述

先感谢您。

答案1

改变线路

\cmidrule(l){4-5} \cmidrule(l){6-7} \cmidrule(l){8-9} \cmidrule(l){10-11}

\cmidrule(l){2-3} \cmidrule(l){4-5} \cmidrule(l){6-7} \cmidrule(l){8-9}

括号中的数字对应于每条规则应跨越的列。您的列从 1 到 9,因此\cmidrule(l){10-11}会出现有关插入额外对齐制表符的错误,这是 TeX 表示您的数字“超出范围”的方式。

新的输出符合预期:

在此处输入图片描述

编辑:正如 leandriis 在评论中指出的那样,你还应该替换

\begin{tabular}{@{} l *{8}{S[table-format=1.3]} @{}}

由其中之一

\begin{tabular}{@{} l *{8}{S[table-format=-1.3]} @{}}
\begin{tabular}{@{} l *{4}{S[table-format=-1.3]S[table-format=1.3]} @{}}

为减号保留额外的空间(在所有或仅在“平均值”列中),从而消除警告Overfull \hbox

答案2

您想要\cmidrule{2-3}等等:通过该输入,您会收到一条关于“列太多”的错误消息;TeX 会尽力恢复,但应该会修复。

我不会让表格超出边距,而是将其排版\small

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

\begin{document}

\begin{table}[htb!]

\caption{Filtered errors MS-DNS model and extensions with macro factors}
\label{table:filtered_errors_macro}

\begin{threeparttable}
\centering

\small
\setlength\tabcolsep{0pt}

\begin{tabular*}{\textwidth}{
  @{}
  l
  @{\extracolsep{\fill}}
  *{4}{S[table-format=-1.3]S[table-format=1.3]} @{}}
\toprule 
Maturity
& \multicolumn{2}{c}{MS-DNS} 
& \multicolumn{2}{c}{MS-DRA} 
& \multicolumn{2}{c}{MS-TVTP}
& \multicolumn{2}{c@{}}{MS-DNS-X} \\ 
 \cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-7} \cmidrule{8-9}
& {Mean} & {Std.\ dev.} 
& {Mean} & {Std.\ dev.}
& {Mean} & {Std.\ dev.}
& {Mean} & {Std.\ dev.} \\ 
\midrule
3      & -0.066 & 0.063 & -0.070 & 0.345 & -0.139 & 0.330  & -0.229 & 1.608 \\
6      &  0.027 & 0.047 &  0.003 & 0.325 & -0.049 & 0.257  & -0.327 & 3.440 \\
12     & 0.076  & 0.072 &  0.037 & 0.334 & 0.014  & 0.226  & -0.556 & 6.140 \\
24     & 0.025  & 0.025 & -0.002 & 0.330 & 0.020  & 0.228  & -0.898 & 8.853 \\
36     & -0.034 & 0.037 & -0.038 & 0.324 & 0.012  & 0.227  & -1.059 & 9.544 \\
60     & -0.074 & 0.055 & -0.068 & 0.314 & 0.000  & 0.225  & -1.107 & 8.643 \\
84     & -0.032 & 0.026 & -0.050 & 0.304 & 0.010  & 0.222  & -1.013 & 7.118 \\
120    & 0.079  & 0.057 & 0.009 & 0.305 & 0.044  & 0.229  & -0.834 & 5.276\\
\addlinespace
Mean   & 0.000  & 0.048 & -0.022 & 0.323 & -0.011 & 0.243  & -0.753 & 6.328 \\
Median & -0.004 & 0.051 & -0.020 & 0.324 & 0.011  & 0.228  & -0.866 & 6.629 \\
Lower  &        &       &  5     &  0    & 5      & 0         &  0     & 0     
\\
\bottomrule
\end{tabular*}

\begin{tablenotes}[flushleft]\footnotesize\smallskip
 \item \hspace*{-\fontdimen2\font}Note: This table reports filtered errors from the MS-DNS model and its 
extensions with macro factors. The filtered errors are defined as the residuals 
of the measurement equation and are formed by taking the difference of the 
observed yield and its filtered estimate obtained by the Kim filter. For each 
maturity, I present the mean and standard deviation (\textit{Std.\ dev.}). 
Moreover, I show the mean, median and number of maturities for which the mean 
of the extended macro model is lower than the mean of the MS-DNS model in 
absolute terms (\textit{Lower}).
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document} 

在此处输入图片描述

您可以\small通过减少列标题来避免:

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

\begin{document}

\begin{table}[htb!]

\caption{Filtered errors MS-DNS model and extensions with macro factors}
\label{table:filtered_errors_macro}

\begin{threeparttable}
\centering

\setlength\tabcolsep{0pt}

\begin{tabular*}{\textwidth}{
  @{}
  l
  @{\extracolsep{\fill}}
  *{4}{S[table-format=-1.3]S[table-format=1.3]} @{}}
\toprule 
Maturity
& \multicolumn{2}{c}{MS-DNS} 
& \multicolumn{2}{c}{MS-DRA} 
& \multicolumn{2}{c}{MS-TVTP}
& \multicolumn{2}{c@{}}{MS-DNS-X} \\ 
 \cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-7} \cmidrule{8-9}
& {M} & {SD} 
& {M} & {SD}
& {M} & {SD}
& {M} & {SD} \\ 
\midrule
3      & -0.066 & 0.063 & -0.070 & 0.345 & -0.139 & 0.330  & -0.229 & 1.608 \\
6      &  0.027 & 0.047 &  0.003 & 0.325 & -0.049 & 0.257  & -0.327 & 3.440 \\
12     & 0.076  & 0.072 &  0.037 & 0.334 & 0.014  & 0.226  & -0.556 & 6.140 \\
24     & 0.025  & 0.025 & -0.002 & 0.330 & 0.020  & 0.228  & -0.898 & 8.853 \\
36     & -0.034 & 0.037 & -0.038 & 0.324 & 0.012  & 0.227  & -1.059 & 9.544 \\
60     & -0.074 & 0.055 & -0.068 & 0.314 & 0.000  & 0.225  & -1.107 & 8.643 \\
84     & -0.032 & 0.026 & -0.050 & 0.304 & 0.010  & 0.222  & -1.013 & 7.118 \\
120    & 0.079  & 0.057 & 0.009 & 0.305 & 0.044  & 0.229  & -0.834 & 5.276\\
\addlinespace
Mean   & 0.000  & 0.048 & -0.022 & 0.323 & -0.011 & 0.243  & -0.753 & 6.328 \\
Median & -0.004 & 0.051 & -0.020 & 0.324 & 0.011  & 0.228  & -0.866 & 6.629 \\
Lower  &        &       &  5     &  0    & 5      & 0         &  0     & 0     
\\
\bottomrule
\end{tabular*}

\begin{tablenotes}[flushleft]\footnotesize\smallskip
\item \hspace*{-\fontdimen2\font}Note: This table reports filtered errors from 
the MS-DNS model and its extensions with macro factors. The filtered errors are 
defined as the residuals of the measurement equation and are formed by taking 
the difference of the observed yield and its filtered estimate obtained by the 
Kim filter. For each maturity, I present the mean (M,~\textit{Mean}) and standard 
deviation (SD,~\textit{Std.\ dev.}). Moreover, I show the mean, median and number 
of maturities for which the mean of the extended macro model is lower than the 
mean of the MS-DNS model in absolute terms (\textit{Lower}).
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document} 

在此处输入图片描述

相关内容