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 recently had to make a table that came out more or less like this:

\begin{tabular}{|l|l|l|}
\hline
Head 1 & Head 2\\
\hline
1 & \multicolumn{2}{|c|}{A}\\ \hline
2 & \multicolumn{2}{|c|}{B}\\ \hline
3 & \multicolumn{2}{|c|}{C}\\ \hline
4 & Da & Db \\ \hline
5 & \multicolumn{2}{|c|}{E}\\ \hline
6 & \multicolumn{2}{|c|}{F}\\ \hline
\end{tabular}

I was wondering whether it is possible to specify that the row starting with 4 has its second column subdivided instead of specifying that all the other rows have a cell that spans multiple columns.

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

Use a nested tabular:

\begin{tabular}{|l|c|}
\hline
Head 1 & Head 2\\
\hline
1 & A\\ \hline
2 & B\\ \hline
3 & C\\ \hline
4 & \begin{tabular}{@{}c|c@{}}Da & Db\end{tabular} \\ \hline
5 & E\\ \hline
6 & F\\ \hline
\end{tabular}

However you should consider avoiding vertical rules in your table; consult the documentation of the booktabs package.

share|improve this answer
1  
Actually, I always use the booktabs package and never use vertical rules, but I copied this example from somewhere else as it illustrates my problem and my own tables were a bit too large to paste here. –  nvcleemp Jun 26 '12 at 14:27
1  
@nvcleemp The method with a nested tabular may need some fine tuning, depending on the cell that must be split. But it's quite general: for instance it's very handy also for spitting a cell vertically. –  egreg Jun 26 '12 at 14:34
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.