像这样格式化有多个标题的表格吗?

像这样格式化有多个标题的表格吗?

在此处输入图片描述

请参阅下面的描述!

答案1

为此,您需要非常大的文本宽度。

这是一个概念证明。

\documentclass{article}
\usepackage[a4paper,margin=2cm]{geometry}
\usepackage{siunitx,booktabs}
\usepackage{newtxtext,newtxmath}

\newcommand{\header}[1]{%
  \begin{tabular}[t]{@{}c@{}}#1\end{tabular}%
}
\newcommand{\theader}[1]{\smash{\header{#1}}}

\begin{document}

\begin{table}
\setlength{\tabcolsep}{0pt}
\small

\caption{Sources of Growth Rate Differences (\%)\label{SGRD}}

\medskip

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  l
  S[table-format=-1.1]
  S[table-format=-1.2]
  S[table-format=-1.2]
  S[table-format=-1.2]
  S[table-format=-1.2]
  S[table-format=-1.2]
  S[table-format=-1.2]
  S[table-format=-1.2]
  S[table-format=-1.2]
}
\multicolumn{9}{l}{\textbf{Period 2 vs.\ Period 1}}\\
\midrule[\heavyrulewidth]
\multicolumn{1}{c}{\theader{Period 2 vs. \\ Period 1}} &
{\theader{Difference \\ in Growth \\ Rate}} &
\multicolumn{3}{c}{\header{Due to Change in Elasticity \\ of Output with respect to}} &
\multicolumn{3}{c}{\header{Due to Change in \\ Growth Rate of}} &
{\theader{$dy/dx$ \\ oil}} &
{\theader{Local \\ Technical \\ Progress}} \\
\cmidrule{3-5} \cmidrule{6-8}
& & {\header{Tangible \\ Capital}} & {Labor} & {\header{Human \\ Capital}} &
    {\header{Tangible \\ Capital}} & {Labor} & {\header{Human \\ Capital}} \\
\midrule
Canada     & -1.4 & -0.22 & 0.18 & -0.08 & -0.36 & -0.21 & -0.14 & -0.31 & -0.24 \\
France     & -3.1 & \\
W. Germany & -2.9 \\
\bottomrule
\end{tabular*}

\end{table}

\end{document}

在此处输入图片描述

由于\header单元格可以跨行拆分,我将其用于\theader相同目的,但由于这样构建的单元格不占用垂直空间\smash

相关内容