我正在尝试使用多行来使用标题行,但由于某种原因,行仍然停留在中间。这是我的 LaTeX 表格:
\begin{table}
\centering
\begin{tabular}{|c|c|c|c|c|}
\hline
\multicolumn{5}{|c|}{Manual vs old ICY}\\
\hline
\multirow{ 2}{*}{Model}&
\multicolumn{2}{|c|}{Senescent}& \multicolumn{2}{|c|}{Young}\\ \hline
&Raw Count &\%\ day3/day0 &Raw Count &\%\ day3/day0\\ \hline
Manual vs old ICY&0.6482 &0.5074 &0.4397 &0.08118\\ \hline
Manual vs new ICY&0.6482 &0.5074 &0.4397 &0.08118\\ \hline
Manual vs VGG16&0.6482 &0.5074 &0.4397 &0.08118\\ \hline
\end{tabular}
\label{ManualvsoldICY}
\end{table}
答案1
环境{NiceTabular}
提供nicematrix
了一种使用合并单元格和规则绘制此类表格的简单方法。
在 中{NiceTabular}
,您可以使用\Block
水平和垂直合并单元格,并使用hvlines
绘制所有预期规则(尊重块)。
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\begin{NiceTabular}{ccccc}[hvlines]
\Block{1-5}{Manual vs old ICY}\\
\Block{2-1}{Model}&
\Block{1-2}{Senescent}&& \Block{1-2}{Young}\\
&Raw Count &\%\ day3/day0 &Raw Count &\%\ day3/day0\\
Manual vs old ICY&0.6482 &0.5074 &0.4397 &0.08118\\
Manual vs new ICY&0.6482 &0.5074 &0.4397 &0.08118\\
Manual vs VGG16&0.6482 &0.5074 &0.4397 &0.08118\\
\end{NiceTabular}
\end{document}
答案2
一些题外的改进:
\multicolumn{2}{|c|}{...}
你应该写\multicolumn{2}{c|}{...}
- 如果表格没有标题,表格的标签就没有意义。
考虑到上述情况,您的表的 MWE 为:
\documentclass{article}
\usepackage{multirow, makecell}
\setcellgapes{3pt}
\usepackage[skip=1ex]{caption}
\usepackage{xparse}
\NewExpandableDocumentCommand\mcc{O{1}m}
{\multicolumn{#1}{c|}{#2}}
\begin{document}
\begin{table}
\caption{Manual vs old ICY}
\label{ManualvsoldICY}
\centering
\makegapedcells
\begin{tabular}{|l|c|c|c|c|}
\hline
\multirow{2.4}{*}{Model} &
\mcc[2]{Senescent} & \mcc[2]{Young} \\
\cline{2-5}
& Raw Count & \% day3/day0 & Raw Count & \% day3/day0 \\ \hline
Manual vs old ICY
& 0.6482 & 0.5074 & 0.4397 & 0.08118 \\ \hline
Manual vs new ICY
& 0.6482 & 0.5074 & 0.4397 & 0.08118 \\ \hline
Manual vs VGG16
& 0.6482 & 0.5074 & 0.4397 & 0.08118 \\
\hline
\end{tabular}
\end{table}
\end{document}
生成结果: