# How to divide a table row into several columns?

I have a table with two columns. In the first column there is no multiple column. But there are 11 multiple columns in the second column. The format looks like:

 | A |                     B                       |
| _ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |


A and B are headings, and 1, 2, 3, ..., 11 are subheadings of the table. After that there are some rows containing data.

I have tried several ways but cannot do it.

-

## migrated from stackoverflow.comSep 17 '11 at 19:16

This question came from our site for professional and enthusiast programmers.

What you need is the \multicolumn macro:

\documentclass{article}
\begin{document}
\begin{tabular}{|l|*{11}{c|}}
\hline
A & \multicolumn{11}{|c|}{B} \\ \hline
\_ & 1&2&3&4&5&6&7&8&9&10&11 \\ \hline
\end{tabular}
\end{document}


-
Indeed, the key point here being that LaTeX looks at the question the 'other way around': you combine several columns into one. An alternative, for complex layouts, is to nest tabulars. – Joseph Wright Sep 17 '11 at 19:25
I replaced the bulky tabular column definition with a more elegant way, hope that's ok. – doncherry Oct 24 '12 at 20:55