10

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.

0

2 Answers 2

15

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}

output

2
  • 4
    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
    Commented Sep 17, 2011 at 19:25
  • I replaced the bulky tabular column definition with a more elegant way, hope that's ok.
    – doncherry
    Commented Oct 24, 2012 at 20:55
0

Check out this page for easy table creation in Latex. https://www.tablesgenerator.com/

Create your table using GUI on the site and automatically generate Latex code for the table you created.

This site saved a lot of my time! And headache to create table in latex.

You must log in to answer this question.