Overleaf和Latex是每个科研人必会的写作工具了,非常好用,但是对于新手小白就是bbq了。
对于Overleaf中表格的插入方法:
1. 首先在Create LaTeX tables online – TablesGenerator.com上把自己的表格大致做好,把该填的数填上。
2. 然后一键生成Latex代码。
现在我们表格大致做好了,但是有可能没有出现我们预期的效果,例如顶线和底线没有加粗,表头的格式不对。方法下面详细介绍。
方法:这里使用的是\bottomrule ,\toprule,\midrule方法,这里可以实现顶线和底线加粗。
\begin{table}[]
\caption{Video anomaly }
\label{tab:Comparison}
\centering
\begin{tabular}{l|ccc}
\toprule
\multicolumn{1}{l|}{\multirow{2}*{Method}} & \multicolumn{3}{c}{AUC(\%)} \\
\multicolumn{1}{l|}{} & CR Dataset & UCSD-Ped2 & Avenue \\ \midrule
rGAN & \multicolumn{1}{c|}{-} & \multicolumn{1}{c|}{96.2} & 85.8 \\ \bottomrule
\end{tabular}
\end{table}
效果图如下,但是这里的线是不连续的。
问题描述:在我们插入表格的时候,让某列一行分为上下两行,其他列不变,但是通常做出来都很难看,像下面的样子,Method是占了上面的一行,我们希望它在这一行的中间靠左。
方法:所以我们需要用到的是\usepackage{multirow} ,这个宏。
代码如下:
\usepackage{multirow}
\begin{table}[]
\caption{Video anomaly detection results of Computer Room(CR), UCSD-Ped2 and Avenue test set}
\label{tab:Comparison of abnormal detection results}
\centering
\begin{tabular}{l|ccc}
\toprule
\multicolumn{1}{l|}{\multirow{2}*{Method}} & \multicolumn{3}{c}{AUC(\%)} \\
\multicolumn{1}{l|}{} & CR Dataset & UCSD-Ped2 & Avenue \\ \midrule
rGAN\cite{Few-Shot-AD} & \multicolumn{1}{c|}{-} & \multicolumn{1}{c|}{96.2} & 85.8 \\ \bottomrule
\end{tabular}
\end{table}
重点:在Method前面添加{2}*。
效果图如下,看Method位于行中间了。
重要的事情说三遍:导入宏\usepackage{multirow} 导入宏\usepackage{multirow} 导入宏\usepackage{multirow}。
撒花