\documentclass[11pt,authoryear,sort&compress]{report}
\usepackage{booktabs}
\begin{document}
\begin{table}
\footnotesize
\centering
\begin{tabular}{l|ccccccc}
\toprule
% & \multicolumn{2}{c}{Variable} & \multicolumn{2}{c}{0} & \multicolumn{2}{c}{1} \\ \midrule
& \multicolumn{7}{c}{Factor} \\ \midrule
Variable &&& 0 &&& 1 \\ \midrule
Gender && Female & 21.27\% && Male & 78.73\% \\
Married && Others & 10.8\% && Married/Cohabited & 89.2\% \\ \midrule
& \multicolumn{7}{c}{} \\ %\midrule
&& West && East &&Center \\ \midrule
Region && 27.7\% && 41.1\% && 30.2\% \\ \midrule
& \multicolumn{7}{c}{Continuous} \\ \midrule %& \multicolumn{3}{c}{RF}& \multicolumn{3}{c}{GBM}\\ \midrule
& Mean & SD & Median & Min & Max & Skew & Kurt \\ \midrule
Income & 77263.25 &197349.48 &45575.00 &109.00 &5000000 &16.30 &347.98 \\ \bottomrule
\end{tabular}
\caption{Sample description.}
\label{tab:Sample-Description}
\end{table}
\end{document}
答案1
正如 Mico 所评论的,这种表格设计很难理解,而且很难实现,因为行中有 4、5、8 个不同宽度的单元格,所以不能通过简单地合并一些单元格来解决。
我认为最好的解决方案是将其拆分为三个不同的表格,或者完全重新设计表格,或者不使用表格而是使用列表或其他东西。话虽如此,这是一种尝试使其更清晰的方法,使用tabularx
嵌套的 tabularx:
\documentclass[11pt,authoryear,sort&compress]{report}
\usepackage{booktabs,tabulary,array,tabularx}
\usepackage{geometry}
\newcolumntype{z}{>{\arraybackslash\centering}X}
\begin{document}
\begin{table}
\caption{Sample description.}
\centering
\begin{tabularx}{\linewidth}{p{2cm}XcXc}
\toprule
Variable & \multicolumn{4}{c}{Factor} \\\cmidrule(rl){1-1}\cmidrule(rl){2-5}
& \multicolumn{2}{c}{0} & \multicolumn{2}{c}{1} \\
\cmidrule(rl){2-3}\cmidrule(rl){4-5}
Gender & Female \dotfill & 21.27 \% & Male \dotfill & 78.73 \% \\
Married & Others \dotfill & 10.80 \% & Married/Cohabited \dotfill & 89.20 \% \\\addlinespace[1em]
Region & \multicolumn{4}{l}{\begin{tabularx}{\dimexpr\linewidth-2cm-4\tabcolsep}{zzz}
West & East & Center \tabularnewline
\cmidrule(r){1-1}\cmidrule(rl){2-2}\cmidrule(l){3-3}
27.7 \% & 41.1 \% & 30.2 \% \tabularnewline\end{tabularx}}
\\\addlinespace[1em]
Income & \multicolumn{4}{c}{%\small%
\begin{tabularx}{\dimexpr\linewidth-2cm-4\tabcolsep}{zzzzzzz}
\multicolumn{7}{c}{\normalsize Continuous}\tabularnewline\midrule
Mean & SD & Median & Min & Max & Skew & Kurt \tabularnewline\midrule
77263.25 &197349.48 &45575.00 &109.00 &5000000 &16.30 &347.98 \tabularnewline\addlinespace[1em]
\end{tabularx}
}\\\bottomrule
\end{tabularx}
\end{table}
\end{document}