如下所示,我的目标是节省一些空间。例如,
Applied
Model
Logistic
Model
我用来生成表的代码是:
\begin{table}[ht]
\renewcommand{\arraystretch}{1}
\addtolength{\tabcolsep}{-5pt}
\centering
{\scriptsize
\begin{tabular}{llccc}
\hline
Algorithm & Dataset & Applied Model (\%) & Definition of data (\%) & Overall Assumptions (\%) \\ \hline
\multirow{3}{*}{Logistic MODEL} & + & 63.6 & 98 & 95.3937 \\
& - & 68.1 & 95.5 & 95.4757 \\
& - & 100 & 100 & 99.1935 \\ \hline
\end{tabular}}
\label{table:tex-exchange}
\end{table}
答案1
您可以使用\multicolumn
来覆盖列规范,然后将标题文本放在里面\parbox
(我将每个里面的文本居中\parbox
,但这当然是可选的);以下对代码的修改说明了这种方法:
\documentclass{article}
\usepackage{booktabs}
\usepackage{multirow}
\newcommand\MyHead[2]{%
\multicolumn{1}{l}{\parbox{#1}{\centering #2}}
}
\begin{document}
\begin{table}[ht]
\addtolength{\tabcolsep}{-3pt}
\centering
{\scriptsize
\begin{tabular}{@{}llccc@{}}
\toprule
Algorithm & Dataset & \MyHead{1.3cm}{Applied\\ Model (\%)}
& \MyHead{1.5cm}{Definition\\ of data (\%)}
& \MyHead{2.2cm}{Overall\\ Assumptions (\%)} \\
\cmidrule(r){1-1}\cmidrule(rl){2-2}\cmidrule(rl){3-3}\cmidrule(rl){4-4}\cmidrule(l){5-5}
\multirow{3}{*}{\parbox{1cm}{Logistic\\ MODEL}} & + & 63.6 & 98 & 95.3937 \\
& $-$ & 68.1 & 95.5 & 95.4757 \\
& $-$ & 100 & 100 & 99.1935 \\
\bottomrule
\end{tabular}}
\label{table:tex-exchange}
\end{table}
\end{document}
编辑:另一个选项是使用多行手动拆分标题文本:
\documentclass{article}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}
\begin{table}[ht]
\addtolength{\tabcolsep}{-3pt}
\centering
{\scriptsize
\begin{tabular}{@{}llccc@{}}
\toprule
Algorithm & Dataset & Applied & Definition & Overall \\
& & Model (\%) & of data (\%) & Assumptions (\%) \\
\cmidrule(r){1-1}\cmidrule(rl){2-2}\cmidrule(rl){3-3}\cmidrule(rl){4-4}\cmidrule(l){5-5}
\multirow{3}{*}{\parbox{1cm}{Logistic\\ MODEL}} & + & 63.6 & 98 & 95.3937 \\
& $-$ & 68.1 & 95.5 & 95.4757 \\
& $-$ & 100 & 100 & 99.1935 \\
\bottomrule
\end{tabular}}
\label{table:tex-exchange}
\end{table}
\end{document}
请注意,我擅自使用了书签包;当然,这个建议完全是可选的。