[Tex/LaTex] ! Missing number, treated as zero, for creating table in Latex

multirowtables

I'm trying to create the following table. This is the code which I wrote.

\begin{table}[!htb]
\centering
\caption{"table1"}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
System & \multicolumn{2}{c}{Interaction} & \multicolumn{2}{c}{Commit} & Ver & LOC & terms \\\hline \multirow{3}{c}{System1} & \multicolumn{2}{c}{3272 traces} & \multicolumn{2}{c}{5093 revisions} & \multirow{3}{c}{3.4} & \multirow{3}{c}{1700} & \multirow{3}{c}{2400} \\\hline
& File & Method & File & Method & & & \\\hline
& 12 & 13 & 14 & 15 & & & \\\hline
 \end{tabular}
\end{table}

and this the error that Latex shows:! Missing number, treated as zero.!

enter image description here

Best Answer

The second argument for \multirow should be a length (representing the width to which the text is to be set) or * to indicate that the text argument’s natural width is to be used.

\documentclass{article}
\usepackage{multirow}

\begin{document}

\begin{table}[!htb]
\centering
\caption{"table1"}
\begin{tabular}{*{8}{|c}|}
\hline
System & \multicolumn{2}{c}{Interaction} & \multicolumn{2}{c}{Commit} & Ver & LOC & terms \\\hline \multirow{3}{*}{System1} & \multicolumn{2}{c}{3272 traces} & \multicolumn{2}{c}{5093 revisions} & \multirow{3}{*}{3.4} & \multirow{3}{*}{1700} & \multirow{3}{*}{2400} \\\hline
& File & Method & File & Method & & & \\\hline
& 12 & 13 & 14 & 15 & & & \\\hline
 \end{tabular}
\end{table}

\end{document}

enter image description here

By the way, using vertical rules in tables might be frown upon. The booktabs package offers you features to increase the quality of your tables.

Here's a version using booktabs (and caption); notice that (at least, in my opinion) the table looks better without the \multirows:

\documentclass{article}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{multirow}

\begin{document}

\begin{table}[!htb]
\centering
\caption{"table1"}
\begin{tabular}{*{8}{c}}
\toprule
System & \multicolumn{2}{c}{Interaction} & \multicolumn{2}{c}{Commit} & Ver & LOC & terms \\
\midrule 
System1 & \multicolumn{2}{c}{3272 traces} & \multicolumn{2}{c}{5093 revisions} & 3.4 & 1700 & 2400 \\
\cmidrule(r){2-3}\cmidrule(r){4-5}
& File & Method & File & Method & & & \\
\cmidrule(r){2-2}\cmidrule(lr){3-3}\cmidrule(lr){4-4}\cmidrule(l){5-5}
& 12 & 13 & 14 & 15 & & & \\
\midrule
System2 & \multicolumn{2}{c}{3272 traces} & \multicolumn{2}{c}{5093 revisions} & 3.4 & 1700 & 2400 \\
\cmidrule(r){2-3}\cmidrule(r){4-5}
& File & Method & File & Method & & & \\
\cmidrule(r){2-2}\cmidrule(lr){3-3}\cmidrule(lr){4-4}\cmidrule(l){5-5}
& 12 & 13 & 14 & 15 & & & \\
\bottomrule
 \end{tabular}
\end{table}

\end{document}

enter image description here

Related Question