我正在嘗試使用多行來使用行作為標題,但由於某種原因,該行仍然保留在中間。這是我的 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}
其產生: