tags:

views:

2453

answers:

3

Hi

I simple want to combine some cells in a row of a table in Latex. For instance, I tried to compile the following table:

\begin{tabular}{|l|l|l|}  
\hline  
\multicolumn{3}{|c|}{Team sheet} \\  
\hline  
Goalkeeper & GK & Paul Robinson \\ \hline  
\multirow{4}{*}{Defenders} & LB & Lucus Radebe \\  
 & DC & Michael Duberry \\  
 & DC & Dominic Matteo \\  
 & RB & Didier Domi \\ \hline  
\multirow{3}{*}{Midfielders} & MC & David Batty \\  
 & MC & Eirik Bakke \\  
 & MC & Jody Morris \\ \hline  
Forward & FW & Jamie McMaster \\ \hline  
\multirow{2}{*}{Strikers} & ST & Alan Smith \\  
 & ST & Mark Viduka \\  
\hline  
\end{tabular}

Then I get the error:

! Undefined control sequence.  
<recently read> \multirow  

l.821 \multirow

Does anyone have an idea what I am doing wrong? Do I need a special package? Interestingly enough, the multicolumn command is working! Weird.

+1  A: 

EDIT: You don't want to combine cells in a row, as you have wrote, but you want to combine cells in one column. Simply write empty cells:

\begin{tabular}{|l|l|l|}  
\hline  
\multicolumn{3}{|c|}{Team sheet} \\  
\hline  
Goalkeeper & GK & Paul Robinson \\ \hline  
Defenders & LB & Lucus Radebe \\  
 & DC & Michael Duberry \\  
 & DC & Dominic Matteo \\  
 & RB & Didier Domi \\ \hline  
Midfielders & MC & David Batty \\  
 & MC & Eirik Bakke \\  
 & MC & Jody Morris \\ \hline  
Forward & FW & Jamie McMaster \\ \hline  
Strikers & ST & Alan Smith \\  
 & ST & Mark Viduka \\  
\hline  
\end{tabular}
Mnementh
Sorry, don't think so: multicolumn would stretch the label "Defenders" over four columns, which makes no sense: names are always in the third column. Moreover, the argument is exactly the number of lines until the next call to multicolumn / -row.
Martijn
Sorry, I got the question wrong. Now it should be right.
Mnementh
+5  A: 

Multirow is not a defined command. This is because of the structure of tables in LaTeX: line by line. You can use the \cline command to make sure that horizontal lines between rows do not separate the first column, but the label "Defenders" would still be at the top of the cell.

It seems that the multirow package (which comes with the complete MikTeX distribution) addresses this issue.

See also:
Manual of the multirow package
Small tutorial on multirow

Martijn
+3  A: 

How about trying

\usepackage{multirow}

?

Key
Yep, I can confirm that this works.
Will Robertson