我想在 LaTeX 中重新创建下表。
我能够使用下面提供的代码制作大部分表格。我找到了制作具有多个维度的表格的代码这里但这并不是我想要的。
\begin{center} \begin{tabular}{ccc} \toprule & \multicolumn{2}{c}{Death
Penalty}
\\ \cmidrule{2-3} Defendant's Race & Yes & No\\ \midrule
White & 19& 132\\
Black & 11& 52\\
White & 0& 9\\
Black & 6& 97\\
\bottomrule \end{tabular} \end{center}
我尝试了以下代码,但没有成功。如能得到任何帮助我将不胜感激!
\begin{center} \begin{tabular}{cccc} \toprule & \multicolumn{2}{c}{Death
Penalty}
\\ \cmidrule{3-4} Victim's Race &Defendant's Race & Yes & No\\ \midrule
White & White & 19& 132\\
&Black & 11& 52\\
Black&White & 0& 9\\
Black & 6& 97\\
\bottomrule \end{tabular} \end{center}
答案1
Fran 的速度稍微快了一点他们的答案multirow
。但是,下面是使用、 和 的略微不同的布局siunitx
:
\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{multirow}
\usepackage{makecell}
\begin{document}
\begin{tabular}{cc*{2}{S[table-format=2]}}
\toprule
& & \multicolumn{2}{c}{Death Penalty} \\
\cmidrule{3-4}
\multirow{-2.5}{*}{\makecell{Victim's\\ Race}} & \multirow{-2.5}{*}{\makecell{Defendant's\\ Race}} & {Yes} & {No}\\
\midrule
White & White & 19& 132\\
&Black & 11& 52\\ \addlinespace
Black&White & 0& 9\\
& Black & 6& 97\\
\bottomrule
\end{tabular}
\end{document}
答案2
选择您喜欢的一个:
\documentclass[twocolumn]{article}
\usepackage{booktabs,lipsum,parskip}
\usepackage{multirow}
\begin{document}
\lipsum[1][1-4]
\begin{table}[h]
\caption{Number of deaths per involved races.}
\begin{tabular}{@{}lccc@{}}
\toprule
& & \multicolumn{2}{c}{Death Penalty}\\\cmidrule{3-4}
Victim's Race & Defendant's Race & Yes & No\\ \midrule
White & White & 19& 132\\
& Black & 11& 52\\
Black & White & 0& 9\\
& Black & 6& 97\\\bottomrule
\end{tabular}
\end{table}
\lipsum[2][7-10]
\newpage
\lipsum[1][1-4]
\begin{table}[h]
\caption{Number of deaths per involved races.}
\centering
\begin{tabular}{llrr}
\toprule
\multirow{2}{*}{\parbox{4em}{Victim's Race}} & \multirow{2}{*}{\parbox{6em}{Defendant's Race}} & \multicolumn{2}{c}{Death Penalty}\\\cmidrule{3-4}
& & Yes & No\\ \midrule
White & White & 19& 132\\
& Black & 11& 52\\
Black & White & 0& 9\\
& Black & 6& 97\\\bottomrule
\end{tabular}
\end{table}
\lipsum[2][7-10]
\end{document}