答案1
重现图片并不难;关键是要有两个t
操作对齐的tabular
环境。
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}[htp]
\centering
\begin{tabular}[t]{lr}
\textbf{Metric} & \textbf{Percent} \\
\toprule
\textbf{Gender} \\
Male & 54 \\
Female & 46 \\
\midrule
\textbf{Education} \\
B.S. or above & 49 \\
Some college & 39 \\
H.S. or below & 13 \\
\midrule
\textbf{Age} \\
18-29 years & 34 \\
30-49 years & 55 \\
50-64 years & 9 \\
65+ years & 1 \\
\midrule
\end{tabular}
\begin{tabular}[t]{lr}
\textbf{Metric} & \textbf{Percent} \\
\toprule
\textbf{Ethnicity} \\
Caucasian & 78 \\
African Am. & 10 \\
Asian & 1 \\
Hispanic & 7 \\
\midrule
\textbf{Smartphone} \\
\textbf{Use} \\
9+ & 10 \\
6-9 & 13 \\
3-6 & 38 \\
0-3 & 39 \\
No smartphone & $<$1 \\
\bottomrule
\end{tabular}
\caption{Whatever}
\end{table}
\end{document}
改进的版本规则更少,并且使用短破折号代替连字符。
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}[htp]
\centering
\begin{tabular}{@{}c@{}}
\toprule
\begin{tabular}[t]{@{}lr@{}}
Metric & Percent \\
\midrule
\textit{Gender} \\
Male & 54 \\
Female & 46 \\
\addlinespace
\textit{Education} \\
B.S. or above & 49 \\
Some college & 39 \\
H.S. or below & 13 \\
\addlinespace
\textit{Age} \\
18--29 years & 34 \\
30--49 years & 55 \\
50--64 years & 9 \\
65+ years & 1 \\
\end{tabular}\qquad
\begin{tabular}[t]{@{}lr@{}}
Metric & Percent \\
\midrule
\textit{Ethnicity} \\
Caucasian & 78 \\
African Am. & 10 \\
Asian & 1 \\
Hispanic & 7 \\
\addlinespace
\textit{Smartphone use} \\
9+ & 10 \\
6--9 & 13 \\
3--6 & 38 \\
0--3 & 39 \\
No smartphone & $<$1 \\
\end{tabular} \\
\bottomrule
\end{tabular}
\caption{Whatever}
\end{table}
\end{document}
答案2
一个简单的例子——下次一定要尝试展示你的努力,因为在表格内容中输入所有细节是很累人的
\documentclass[12pt,letterpaper]{article}
\usepackage[left=20mm,top=30mm,bottom=30mm,right=20mm]{geometry}
\usepackage{booktabs} % format SI units
\begin{document}
\begin{table}
\centering
\caption{Example of two independent sub-tables with booktabs package}
\begin{tabular}{lr}
% \toprule
\textbf{Metric} & \textbf{Percent} \\
\toprule
\textbf{Gender} & \\
1 & 2 \\
\midrule
\textbf{Education} & \\
3 & 4 \\
\bottomrule
\end{tabular}
\quad
\begin{tabular}{lr}
% \toprule
\textbf{Metric} & \textbf{Percent} \\
\toprule
\textbf{Ethnicity} & \\
5 & 6 \\
\midrule
\textbf{Smartphone} & \\
7 & 8 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}