# Weird multicolumn spacing

Looking at the question Defining a number of columns different to 1 in a multicolumn, my first thought was to try something like this:

\documentclass{article}

\newcommand\Two[1]{\multicolumn{2}{|c|}{#1}}
\newcommand\Thr[1]{\multicolumn{3}{|c|}{#1}}
\newcommand\Six[1]{\multicolumn{6}{|c|}{#1}}

\begin{document}

$\begin{array}{*6c}\hline \Six{A}\\\hline \Two{B}&\Two{C}&\Two{D}\\\hline \Two{E}&\Two{F}&\Two{G}\\\hline \Thr{H}&\Thr{I}\\\hline \Thr{J}&\Thr{K}\\\hline \end{array}$

\end{document}


Unfortunately, for reasons that I'd don't understand this produces:

Why are H and J occupying only two and a bit columns, and I and K almost four columns, when all of these should occupy three columns? Incidentally, I get the same output if I expand the helper macros:

\documentclass{article}

\begin{document}

$\begin{array}{*6c}\hline \multicolumn{6}{|c|}{A}\\\hline \multicolumn{2}{|c|}{B}&\multicolumn{2}{|c|}{C}&\multicolumn{2}{|c|}{D}\\\hline \multicolumn{2}{|c|}{E}&\multicolumn{2}{|c|}{F}&\multicolumn{2}{|c|}{G}\\\hline \multicolumn{3}{|c|}{H}&\multicolumn{3}{|c|}{I}\\\hline \multicolumn{3}{|c|}{J}&\multicolumn{3}{|c|}{K}\\\hline \end{array}$

\end{document}


The output I expected was something like this:

-------------
|     A     |
-------------
| B | C | D |
-------------
| E | F | G |
-------------
|  H  |  I  |
-------------


Note This question is not a duplicate of Defining a number of columns different to 1 in a multicolumn as the other post asks for code to produce the picture above whereas this question asks why the code above does not produce this picture. To put it another way, Mico has provided a correct answer to my silly question but his answer is not an answer to the other post.

• Because you have nothing in your second column, so its width is practically inexistent. – TeXnician Aug 4 '17 at 14:39
• Possible duplicate of Defining a number of columns different to 1 in a multicolumn – Zarko Aug 4 '17 at 15:02
• @zarko No, it's not a duplicate. This question is asking why the code above fails to be a solution to the so-called duplicate, which is not the same as the question asked in the other post. (OK, this is a silly question, but I am not sure that this provides sufficient grounds for closing it.) – Andrew Aug 4 '17 at 15:07
• BTW: At least if you are using package array (used by several other packages like tabularx), you should not use \multicolumn{…}{|…|}{…} but \multicolumn{…}{…|}{…} for all cells but the first one. Otherwise you would get double vertical rules between cells, that look like fat rules. – Schweinebacke Aug 4 '17 at 15:46
• @Schweinebacke True. My preference, for the reasons explained in the booktabs manual, is not to use vertical rules at all in tables. I had them only because the post that motivated this used them:) – Andrew Aug 4 '17 at 22:23

Why are H and J occupying only two and a bit columns?

The letters "H" and "J" are actually occupying 3 full columns, even though it doesn't look that way at first. What's going on?

You're using the basic c column type for the three-column cells, and the c column type has no predefined width. The width of the 3-column cells that contain "H" and "J", respectively, is set dynamically to fit whatever is the wider of the two letters (which happens to be "H"). And, since "H" is slightly wider than either "B" or "E", the "H" and "J" three-column cells are slightly wider than the "B" and "E" two-column cells. (The width of math-italic-H is 9.12pt, whereas the width of math-italic-B is 8.09pt -- assuming that the Computer Modern font is used at 10pt.)

Moreover, if one stares really carefully at your screenshot, one notices that the widths of B/E, C/F, and D/G two-column cells aren't exactly the same. The widths are given by 8.09pt+2\tabcolsep, 7.86pt+2\tabcolsep, and 8.56pt+2\tabcolsep, respectively. Close, but not identical...

The widths of the "I" and "K" three-column cells are calculated as a residual -- the overall width of the tabular environment, minus the width of the "H" cells. Finally, the width of the six-column "A" cell is calculated as the simple sum of the widths of the three two-column cells in the next two rows.

The solution is not to use the c column type at all. Instead, one needs to use fixed-width columns, as is done in this answer.

• Mea culpa! Thanks, I should have realised this but missed it (+35:) – Andrew Aug 4 '17 at 15:03
• @Andrew - And I just corrected the calculations of the cell widths. (I was initially using text-italic letters, whereas your code uses math-italic letters...) – Mico Aug 4 '17 at 15:15