Latex 中表格的子标题

Latex 中表格的子标题

这张照片来自掌握指标,是我正在寻找的一个例子我正在创建一个表格,需要帮助制作列标签的子部分。这是我的代码:

\begin{table}[tbp] \centering
\newcolumntype{C}{>{\centering\arraybackslash}X}
\caption{WAGE SAMPLE STATISTICS, by year and state (1983-2000)}
\begin{tabularx}{\textwidth}{lCCCCCCC}

\toprule \toprule
{state}&{1983}&{1987}&{1988}&{1993}&{1994}&{1999}&{2000} 
\tabularnewline
\midrule\addlinespace[1.5ex]
Andhra Pradesh&5.17&5.49&5.53&6.28&6.24&5.77&5.80 \tabularnewline
Gujarat&9&6.04&5.92&6.64&6.58&6.09&6.04 \tabularnewline
Haryana&12&6.25&6.43&6.80&6.60&6.54&6.74 \tabularnewline
Manipur&54&6.31&6.73&7.15&7.09&6.90&6.83 \tabularnewline
Orissa&5.24&5.90&5.96&6.16&6.26&5.57&5.58 \tabularnewline
Tamil Nadu&5.19&5.67&5.68&6.31&6.33&6.02&5.97 \tabularnewline
Uttar Pradesh&5.55&6.06&3&6.61&2&6.00&6.07 \tabularnewline
Mizoram&6.43&5.44&6.03&6.81&6.76&8&7 \tabularnewline
\bottomrule \addlinespace[1.5ex]

\end{tabularx}
\end{table}

booktabs 和 tabularx 是相关包。我认为它们很常见,但如果不常见,我可以评论更多细节!我从 Stata 创建的文本文件中复制粘贴了此内容。基本上,我需要用居中的子部分标签对最后 7 列进行子部分标记,并希望在其下方添加一行以使其看起来不错。我真的不知道该怎么做。有人有什么提示吗?

所附照片来自 Mastering Metrics,是我所寻找的一个例子。

答案1

这个怎么样?tabularx不需要,我认为 columntypeS更适合数字对齐。

    \documentclass{article}
    \usepackage{tabularx, booktabs, makecell, caption}
    \usepackage{siunitx}
    \begin{document}

\begin{table}[tbp] \centering
\newcolumntype{C}{>{\centering\arraybackslash}X}
\sisetup{table-format=1.2, table-number-alignment=center}
\caption{WAGE SAMPLE STATISTICS, by year and state (1983-2000)}
%\begin{tabularx}{\textwidth}{l*{7}{S}}%{lCCCCCCC}
\begin{tabular}{lS[table-format=2.2]*{6}{S}}%{lCCCCCCC}

\toprule \toprule
\addlinespace
 & \multicolumn{7}{c}{\makecell{Logged mean wages \\ in year}} \\
 \cmidrule(lr){2-8}
{state}&{1983}&{1987}&{1988}&{1993}&{1994}&{1999}&{2000}
\tabularnewline
\cmidrule[\lightrulewidth](lr){1-8}\addlinespace[1ex]
Andhra Pradesh&5.17&5.49&5.53&6.28&6.24&5.77&5.80 \tabularnewline
Gujarat&9&6.04&5.92&6.64&6.58&6.09&6.04 \tabularnewline
Haryana&12&6.25&6.43&6.80&6.60&6.54&6.74 \tabularnewline
Manipur&54&6.31&6.73&7.15&7.09&6.90&6.83 \tabularnewline
Orissa&5.24&5.90&5.96&6.16&6.26&5.57&5.58 \tabularnewline
Tamil Nadu&5.19&5.67&5.68&6.31&6.33&6.02&5.97 \tabularnewline
Uttar Pradesh&5.55&6.06&3&6.61&2&6.00&6.07 \tabularnewline
Mizoram&6.43&5.44&6.03&6.81&6.76&8&7 \tabularnewline
\addlinespace
\bottomrule
\end{tabular}
\end{table}
\end{document} 

在此处输入图片描述

相关内容