views:

2019

answers:

1

This is probably best explained with an example. I have the following table, where the "A" cell spans two rows, and the "B" cell spans two columns.

\begin{table}[htdp]
\begin{tabular}{l|r|r}
\multirow{2}{*}{A} & \multicolumn{2}{c}{B} \\
  & B1 & B2 \\
a & b1 & b2 \\
a & b1 & b2 \\
\end{tabular}
\end{table}
 _ _ _ _ _ _ _ _ _ _ _ _ 
|A      |_ _ _ _B_ _ _ _|
|_ _ _ _|_ _B1_ |_ _B2_ |
|a      |     b1|     b2|
|a      |     b1|     b2|
|a      |     b1|     b2|
|_ _ _ _| _ _ _ |_ _ _ _|

I would like to center the text in the "A" cell, only. I would like to leave the rest of the column left-aligned. Giving:

 _ _ _ _ _ _ _ _ _ _ _ _ 
|   A   |_ _ _ _B_ _ _ _|
|_ _ _ _|_ _B1_ |_ _B2_ |
|a      |     b1|     b2|
|a      |     b1|     b2|
|a      |     b1|     b2|
|_ _ _ _| _ _ _ |_ _ _ _|

I'm sure this must be simple to do, but I can't seem to put my finger on it.

+1  A: 

I think you need to do that with a fake \multicolumn:

\multicolumn{1}{c}{\multirow{2}{*}{A}} & \multicolumn{2}{c}B} \\

Inspiration from this FAQ.

Dave
That gives: ! Misplaced \omit. \multispan -> \omit \@multispan. Not sure what that means :-S
Paul
Try swapping the nesting of the multirow/multicolumn? (so the multicolumn is on the outside). Sorry, I haven't got a working LaTeX install here to play with!
Dave
Genius, thanks. Works like a charm :-)
Paul
Edited answer to put multirow inside multicolumn instead of the other way round -- sorry, I think I got the nesting backwards!
Dave
Glad I could help :-)
Dave