9

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

2
  • Where exactly does it complain? At first sight, the above looks fine.
    – vonbrand
    Feb 1, 2014 at 0:15
  • first of fifth line. :(
    – Sara
    Feb 1, 2014 at 0:16

1 Answer 1

5

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

2
  • it looks nice, I used \cline{} to add a partial line for rows. But I have a problem with cell alignment, I want a vertical and horizontal centering for each cell.
    – Sara
    Feb 1, 2014 at 0:57
  • @Sara consider opening a fresh new question with this new issue; don't forget to include there a minimal version of your code. Feb 1, 2014 at 1:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .