我在这里有这个表格代码:
\documentclass{article}
\usepackage{longtable}
\usepackage{booktabs,amsmath,bm,siunitx}
\usepackage{lscape}
\usepackage{threeparttable}
\DeclareMathOperator{\Var}{Var}
\DeclareMathOperator{\Cov}{Cov}
\begin{table}
\caption{Variability of Asset Demands: Bond Model}
\label{my-label}
\setlength{\tabcolsep}{4pt}
\begin{threeparttable}
% \begin{tabular}{@{}l@{}}
\begin{tabular*}{\textwidth}{l*3{S[table-format=2.2]}}
\toprule
\multicolumn{4}{c}{${\gamma =5,\ \psi = 1,\ \rho =0.92^{1/4} }$}\\
\midrule
&{${\Var(\alpha^m)/\Var(\alpha)}$}& {${\Var(\alpha^h)/\Var(\alpha)}$} &{${\Cov(\alpha^m,\alpha^h)/\Var(\alpha)}$}\\
& {(\%)} & {(\%)} & {(\%)} \\
\cmidrule(rl){2-2} \cmidrule(rl){3-3} \cmidrule(rl){4-4}
Stock & 81.27 & 22.18 & -1.73\\
Bond & 76.53 & 4.10 & 9.69\\
\end{tabular*}
\begin{tabular*}{\textwidth}{@{\hspace{5ex}}r*2{S[table-format=1.4]}*6{S[table-format=-1.4]}}
\midrule
\multicolumn{8}{c}{Percentage of Total Variation Explained By:}\\
\multicolumn{1}{l}{IG} \\
&{$rtb_t$} & {$IG_t$ } & {$HY_t$} &{$EM_t$} & {$Conv_t$} & {$y_t$} & {$DefRate_t$} & {$spr_t$} \\
$rtb_t$ & 26.69 & 0.87 & 1.69 & -0.12 & 2.98 & -7.92 &-22.76 & 7.84\\
$IG_t$ &&5.77 & 3.59 & -0.22 & 2.97 & 1.16 & -3.63 & 2.67\\
$HY_t$ &&&7.20 & -0.25 & 7.07 & 1.17 & -3.59 & 2.03\\
$EM_t$ &&&&0.01 & -0.2651 & -0.0295 & 0.1845 & -0.11\\
$Conv_t$ &&&&&12.28 & 0.7497 & -2.6121 &-0.41\\
$y_t$ &&&&&&7.86 & 5.2971 & 0.77\\
$DefRate_t$&&&&&&&61.95& -27.92\\
$spr_t$ &&&&&&&&35.74\\
\addlinespace
\multicolumn{1}{@{\hspace{\tabcolsep}}l}{HY} \\
&{$rtb_t$} & {$IG_t$ } & {$HY_t$} &{$EM_t$} & {$Conv_t$} & {$y_t$} & {$DefRate_t$} & {$spr_t$}\\
$rtb_t$ & 14.70 & 0.16 & 1.40 & -4.91 & -1.70 & 6.48 & -1.80 & -5.57\\
$IG_t$ &&0.34 & 0.98 & -3.05 & -0.56 & -0.31 & -0.09 & -0.62\\
$HY_t$ &&& 8.97 & -15.84 & -6.09 & -1.45 & -0.42 & -2.17\\
$EM_t$ &&&&49.71 & 11.25 & 1.79& 1.08 & 5.82\\
$Conv_t$ &&&&& 7.31 & 0.63 & 0.21 & -0.30\\
$y_t$ &&&&&& 9.56 & -0.62 & 0.81\\
$DefRate_t$&&&&&&&0.71 & 2.86\\
$spr_t$ &&&&&&&&32.77\\
\addlinespace
\multicolumn{1}{@{\hspace{\tabcolsep}}l}{EM} \\
&{$rtb_t$} & {$IG_t$ } & {$HY_t$} &{$EM_t$} & {$Conv_t$} & {$y_t$} & {$DefRate_t$} & {$spr_t$}\\
$rtb_t$ & 74.95 & 4.61 & 2.34 & -15.03 & 3.20 & 16.22 & -31.82 & 6.86\\
$IG_t$ && 56.52 & 9.27 & -52.73 & 5.96 & -4.47 & -9.49 & 4.37\\
$HY_t$ &&& 4.89 & -15.83 & 3.73 & -1.18 & -2.47 & 0.87\\
$EM_t$ &&&&91.09 &-12.65 & 2.68& 11.46& -4.30\\
$Conv_t$ &&&&& 5.04 & -0.58 & -1.39 & -0.13\\
$y_t$ &&&&&& 11.74 & -5.40 & -0.49\\
$DefRate_t$&&&&&&&43.12 & -12.17\\
$spr_t$ &&&&&&&&9.76\\
\addlinespace
\multicolumn{1}{@{\hspace{\tabcolsep}}l}{Conv} \\
&{$rtb_t$} & {$IG_t$ } & {$HY_t$} &{$EM_t$} & {$Conv_t$} & {$y_t$} & {$DefRate_t$} & {$spr_t$}\\
$rtb_t$ & 24.30 & -1.81 & 1.68 & 0.37 & -4.08& -12.49 & 7.80 & -12.37\\
$IG_t$ && 27.10 & -8.09 & -1.60 & 9.26 & -4.18 &-2.83 & 9.58\\
$HY_t$ &&& 7.78 & 0.87 &-10.56 & 2.02 & 1.34 & -3.49\\
$EM_t$ &&&&0.17 & -1.24 & 0.15 & 0.21 & -0.60\\
$Conv_t$ &&&&& 25.36 & -1.78 & -1.34 & -0.97\\
$y_t$ &&&&&&21.47 & -3.14 & -2.11\\
$DefRate_t$&&&&&&&8.00& -16.60\\
$spr_t$ &&&&&&&&97.88\\
\bottomrule
\end{tabular*}
% \end{tabular}
\begin{tablenotes}
\item[] \textbf{Note:} Here can be the table notes
\end{tablenotes}
\end{threeparttable}
\end{table}
它的输出是这样的:
我不明白如何在第一个面板下方的矩阵中将线延伸到变量上方。你知道我做错了什么吗?提前谢谢。
答案1
第一个环境中缺少一个@{\extracolsep{\fill}}
指令tabular*
。对于第二个tabular*
环境,我认为主要的调整应该包括为 类型的八列提供更精确的格式信息S
。
\documentclass{article}
\usepackage{booktabs,amsmath,bm,siunitx}
\usepackage[flushleft]{threeparttable}
\DeclareMathOperator{\Var}{Var}
\DeclareMathOperator{\Cov}{Cov}
\newcommand\vn[1]{\mathrm{#1}} % "variable name" shortcut macro
\begin{document}
\begin{table}
\setlength{\tabcolsep}{0pt} % make LaTeX figure out optimal intercol. space
\begin{threeparttable}
\caption{Variability of Asset Demands: Bond Model}
\label{my-label}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
l*3{S[table-format=2.2]}}
\toprule
\multicolumn{4}{c}{$\gamma =5$, $\psi = 1$, $\rho =0.92^{1/4}$ }\\
\midrule
& {${\Var(\alpha^m)/\Var(\alpha)}$}
& {${\Var(\alpha^h)/\Var(\alpha)}$}
& {${\Cov(\alpha^m,\alpha^h)/\Var(\alpha)}$} \\
& {(\%)} & {(\%)} & {(\%)} \\
\cmidrule(rl){2-2} \cmidrule(rl){3-3} \cmidrule(l){4-4}
Stock & 81.27 & 22.18 & -1.73\\
Bond & 76.53 & 4.10 & 9.69\\
\bottomrule
\end{tabular*}
\small
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
r S[table-format= 2.2]
*2{S[table-format= 1.2]}
S[table-format=-2.2]
*3{S[table-format=-1.4]
S[table-format= 2.2]}}
\addlinespace
\multicolumn{9}{c}{Percentage of Total Variation Explained by}\\
\addlinespace
\multicolumn{1}{l}{\textbf{IG}}
& {$\vn{rtb}_t$} & {$\vn{IG}_t$ } & {$\vn{HY}_{\!t}$} & {$\vn{EM}_t$}
& {$\vn{Conv}_t$} & {$y_t$} & {$\vn{DefRate}_t$} & {$\vn{spr}_t$} \\
$\vn{rtb}_t$ & 26.69 & 0.87 & 1.69 & -0.12 & 2.98 & -7.92 &-22.76 & 7.84\\
$\vn{IG}_t$ &&5.77 & 3.59 & -0.22 & 2.97 & 1.16 & -3.63 & 2.67\\
$\vn{HY}_{\!t}$ &&&7.20 & -0.25 & 7.07 & 1.17 & -3.59 & 2.03\\
$\vn{EM}_t$ &&&&0.01 & -0.2651 & -0.0295 & 0.1845 & -0.11\\
$\vn{Conv}_t$ &&&&&12.28 & 0.7497 & -2.6121 &-0.41\\
$y_t$ &&&&&&7.86 & 5.2971 & 0.77\\
$\vn{DefRate}_t$&&&&&&&61.95& -27.92\\
$\vn{spr}_t$ &&&&&&&&35.74\\
\addlinespace
\multicolumn{1}{l}{\textbf{HY}}
& {$\vn{rtb}_t$} & {$\vn{IG}_t$ } & {$\vn{HY}_{\!t}$} & {$\vn{EM}_t$}
& {$\vn{Conv}_t$} & {$y_t$} & {$\vn{DefRate}_t$} & {$\vn{spr}_t$} \\
$\vn{rtb}_t$ & 14.70 & 0.16 & 1.40 & -4.91 & -1.70 & 6.48 & -1.80 & -5.57\\
$\vn{IG}_t$ &&0.34 & 0.98 & -3.05 & -0.56 & -0.31 & -0.09 & -0.62\\
$\vn{HY}_{\!t}$ &&& 8.97 & -15.84 & -6.09 & -1.45 & -0.42 & -2.17\\
$\vn{EM}_t$ &&&&49.71 & 11.25 & 1.79& 1.08 & 5.82\\
$\vn{Conv}_t$ &&&&& 7.31 & 0.63 & 0.21 & -0.30\\
$y_t$ &&&&&& 9.56 & -0.62 & 0.81\\
$\vn{DefRate}_t$&&&&&&&0.71 & 2.86\\
$\vn{spr}_t$ &&&&&&&&32.77\\
\addlinespace
\multicolumn{1}{l}{\textbf{EM}}
& {$\vn{rtb}_t$} & {$\vn{IG}_t$ } & {$\vn{HY}_{\!t}$} & {$\vn{EM}_t$}
& {$\vn{Conv}_t$} & {$y_t$} & {$\vn{DefRate}_t$} & {$\vn{spr}_t$} \\
$\vn{rtb}_t$ & 74.95 & 4.61 & 2.34 & -15.03 & 3.20 & 16.22 & -31.82 & 6.86\\
$\vn{IG}_t$ && 56.52 & 9.27 & -52.73 & 5.96 & -4.47 & -9.49 & 4.37\\
$\vn{HY}_{\!t}$ &&& 4.89 & -15.83 & 3.73 & -1.18 & -2.47 & 0.87\\
$\vn{EM}_t$ &&&&91.09 &-12.65 & 2.68& 11.46& -4.30\\
$\vn{Conv}_t$ &&&&& 5.04 & -0.58 & -1.39 & -0.13\\
$y_t$ &&&&&& 11.74 & -5.40 & -0.49\\
$\vn{DefRate}_t$&&&&&&&43.12 & -12.17\\
$\vn{spr}_t$ &&&&&&&&9.76\\
\addlinespace
\multicolumn{1}{l}{\textbf{Conv}}
& {$\vn{rtb}_t$} & {$\vn{IG}_t$ } & {$\vn{HY}_{\!t}$} & {$\vn{EM}_t$}
& {$\vn{Conv}_t$} & {$y_t$} & {$\vn{DefRate}_t$} & {$\vn{spr}_t$} \\
$\vn{rtb}_t$ & 24.30 & -1.81 & 1.68 & 0.37 & -4.08& -12.49 & 7.80 & -12.37\\
$\vn{IG}_t$ && 27.10 & -8.09 & -1.60 & 9.26 & -4.18 &-2.83 & 9.58\\
$\vn{HY}_{\!t}$ &&& 7.78 & 0.87 &-10.56 & 2.02 & 1.34 & -3.49\\
$\vn{EM}_t$ &&&&0.17 & -1.24 & 0.15 & 0.21 & -0.60\\
$\vn{Conv}_t$ &&&&& 25.36 & -1.78 & -1.34 & -0.97\\
$y_t$ &&&&&&21.47 & -3.14 & -2.11\\
$\vn{DefRate}_t$&&&&&&&8.00& -16.60\\
$\vn{spr}_t$ &&&&&&&&97.88\\
\bottomrule
\end{tabular*}
\footnotesize
\begin{tablenotes}
\item[]\textbf{Note:} Here can be the table notes
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}