在 LaTeX 中创建表格

在 LaTeX 中创建表格

我是 LaTeX 新手。请问我该如何创建下表?

我尝试过这样做,但我无法弄清楚如何在没有顶部标题(如 1999、2004 和 2006)的情况下在其他三栏中适应就业类型。

谢谢

在此处输入图片描述

答案1

创建与问题中显示的表格类似的表格的 MWE 将是以下代码:

\documentclass{article}
\usepackage{booktabs}

\begin{document}
\begin{table}
\caption{Types of Employment as Percentage of Sample Population}
\centering
\begin{tabular}{lrrr}
\toprule 
& \textit{1999} & \textit{2004} & \textit{2006} \\
\midrule
Family agriculture & 30.8 & 36.60 & 37.80 \\
Nonagriculture self-employed & 24.1 & 25.80 & 22.90 \\
Nonagriculture unpaid family work & 0 & 0.08 & 0.06 \\
Wage employment & 15.0 & 10.40 & 10.00 \\
Apprenticeship & 2.1 & 1.10 & 1.90 \\
Unemployed & 1.7 & 2.40 & 1.90 \\
Not in the labor force & 26.4 & 23.70 & 25.50 \\
\bottomrule
\footnotesize Source:
\end{tabular}
\end{table}
\end{document}

在此处输入图片描述

您可能需要考虑根据小数点分隔符对齐数字,而不是右对齐。这可以借助包轻松实现,siunitx如以下示例所示:

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}

\begin{table}
\caption{Types of Employment as Percentage of Sample Population}
\centering
\begin{tabular}{l*3S[table-format=2.2]}
\toprule 
& \textit{1999} & \textit{2004} & \textit{2006} \\
\midrule
Family agriculture & 30.8 & 36.60 & 37.80 \\
Nonagriculture self-employed & 24.1 & 25.80 & 22.90 \\
Nonagriculture unpaid family work & 0 & 0.08 & 0.06 \\
Wage employment & 15.0 & 10.40 & 10.00 \\
Apprenticeship & 2.1 & 1.10 & 1.90 \\
Unemployed & 1.7 & 2.40 & 1.90 \\
Not in the labor force & 26.4 & 23.70 & 25.50 \\
\bottomrule
\footnotesize Source:
\end{tabular}
\end{table}
\end{document}

在此处输入图片描述

相关内容