Most of the places, examples for merging of cells in tables are given. But, I could not find a merging of cells in complicated fashion as shown below. This question may summarize all the possible methods of merging and may serve as the reference for all future questions on merging of cells. Experts can add much more complications if required.

Table with merged cells


Here is an extended duplication of your table, with the addition of using some \multirows (from the multirow package) just because you asked about some "more elaborate" cell constructs:

enter image description here

\usepackage{multirow}% http://ctan.org/pkg/multirow
  1a & 2a & 3a & \multicolumn{2}{l|}{4a, 5a} & 6a \\ \hline
  1b & \multicolumn{2}{l|}{2b, 3b} & 4b & 5b & 6b \\ \hline
  1c & 2c & 3c & 4c, 4d & 5c & 6c \\ \cline{1-3}\cline{5-6}
  1d, 1e & 2d & 3d & & 5d & 6d \\ \cline{2-6}
  & 2e & 3e & 4e & 5e & \\ \cline{1-5}
  1f & \multicolumn{2}{l|}{\multirow{2}*{2f, 3f, 2g, 3g}} & 4f & 5f & \multirow{-2}*{6e, 6f}\\ \cline{1-1}\cline{4-6}
  1g & \multicolumn{2}{l|}{} & 4g & 5g & 6g \\ \hline
  \multicolumn{2}{|l|}{1h, 2h} & 3h & 4h & 5h & 6h \\ \hline

Some things to note in such tabular constructs:

  • If your column types are very similar, you can use the *{<num>}{<col spec>} format to duplicate <col spec> a total of <num> times;
  • When using \multicolumn{<num>}{<col spec>}{<stuff>}, you need to include the "end" vertical rule in <col spec>, since the "begin" vertical rule in a single-rule tabular belongs to the previous cell (except if you're spanning from the first column);
  • \multirow{<num>} allows for a negative number <num>, which will raise the entries vertically to the middle of <num> rows. If <num> is positive, the entries are dropped. Raising is useful when you have coloured rows, since the colour is set on a row-by-row basis. So, you may want to finish setting the colour of some upper row, and the \multirow an entry "into" it. For this you would need a negative <num>.

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.