154

I can compile this table separately but when I want to compile the whole file, it gives me an error, which is fixed by removing \multirow.

\usepackage{multirow}

\begin{table}[htbp]
\begin{center}
\begin{tabular}{|c|c|c|c|p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}|}
\hline
A & B & C & D & \multicolumn{7}{|c|}{F}  \\ \hline
\multirow{ 2}{}{1} & 0 & 6 & 230 & 35 & 40 & 55 & 25 & 40 & 35 & \\
& 1 & 5 & 195 & 25 & 50 & 35 & 40 & 45 &  &  \\ \hline
\end{tabular}
\end{center}
\label{table2}
\end{table}
Moriambar
  • 11,466
anna
  • 1,717

3 Answers3

222

There are some errors in your code; you need to give a second argument to \multirow (an explicit value for the cell width or * to use the natural width of the contents); also, \label must always appear after \caption in floating environments:

\documentclass{article}
\usepackage{multirow}

\begin{document}

\begin{table}[htbp]
\centering
\begin{tabular}{|c|c|c|c|p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}|}
\hline
A & B & C & D & \multicolumn{7}{|c|}{F}  \\ \hline
\multirow{ 2}{*}{1} & 0 & 6 & 230 & 35 & 40 & 55 & 25 & 40 & 35 & \\
& 1 & 5 & 195 & 25 & 50 & 35 & 40 & 45 &  &  \\ \hline
\end{tabular}
\caption{A test caption}
\label{table2}
\end{table}

\end{document}

enter image description here

It is not clear why you are using p{...} columns if the cells are not containing paragraphs.

As a side note, I used \centering instead of the center environment to avoid adding extra vertical spacing (which in most cases is not desired).

You are not using all the columns you declared, but I guess that this was just for the example.

Gonzalo Medina
  • 505,128
4

For information, here is how you can construct that table with {NiceTabular} of nicematrix.

In that environment, you merge cells both horizontally and vertically with the built-in command \Block and, with the key hvlines, all rules are drawn, excepted in those blocks.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\begin{table}[htbp] \centering \begin{NiceTabular}{{4}{c}{7}{p{1cm}}}[hvlines] A & B & C & D & \Block{1-*}{F} \ \Block{2-1}{1} & 0 & 6 & 230 & 35 & 40 & 55 & 25 & 40 & 35 & \ & 1 & 5 & 195 & 25 & 50 & 35 & 40 & 45 & & \ \end{NiceTabular} \caption{A test caption} \label{table2} \end{table}

\end{document}

Output of the above code

F. Pantigny
  • 40,250
  • I think it would be better if you disclose yourself as the maintainer of the package based on your profile https://ctan.org/author/pantigny. – Muhammad Yasirroni May 20 '23 at 01:11
4

An alternative solution with tabularray package:

\documentclass{article}

\usepackage{tabularray}

\begin{document}

\begin{table}[htbp] \centering \begin{tblr}{ colspec={|c|c|c|c|p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}p{1cm}|}, hline{1,2,4}, cell{1}{5} = {c=7}{c}, % multicolumn cell{2}{1} = {r=2}{m}, % multirow } A & B & C & D & F & & & & & & \ 1 & 0 & 6 & 230 & 35 & 40 & 55 & 25 & 40 & 35 & \ & 1 & 5 & 195 & 25 & 50 & 35 & 40 & 45 & & \ \end{tblr} \end{table}

\end{document}

enter image description here

L.J.R.
  • 10,932