8

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.

7

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.

2
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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