Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Sep 17 '11 at 19:16

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

add comment

1 Answer 1

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

share|improve this answer
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 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.