1

I am trying to use multirow to use to rows for a heading but for some reason, the line is still remaining in the middle. Here's my LaTeX table:

\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}

enter image description here

leandriis
  • 62,593

2 Answers2

3

The environment {NiceTabular} of nicematrix provides an easy way to draw such tables with merged cells and rules.

In {NiceTabular}, you use \Block to merge cells both horizontally and vertically and you use hvlines to draw all the expected rules (respecting the blocks).

\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}

Ouput of the above code

F. Pantigny
  • 40,250
1

Some off-topic improvement:

  • instead \multicolumn{2}{|c|}{...} you should write \multicolumn{2}{c|}{...}
  • labeling of table hasn't sense if table hasn't caption.

Considering aforementioned the MWE for your table is:

\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}

which produces:

enter image description here

Zarko
  • 296,517