1

I have the following table:

\begin{tabular}{c | c | c | c | c}
 & Front & \multicolumn{2}{|c|}{Center} & Back \\
\hline
Close
  & \multicolumn{2}{|c|}{i}
  & \multicolumn{2}{|c|}{u} \\
\hline
Mid
  & e
  & \multicolumn{2}{|c|}{o} \\
\hline
\end{tabular}

Note that in the second row the cell containing i is made to span 2 columns, and in the third row the cell containing e is made to span only 1. My guess would be just looking at the code that the cell on row 2 would be wider, since it spans more columns. I'd expect the cell containing i to extend to about the midpoint of the cell containing Center.

However, it is not wider. In fact the cell on row 3 is wider.

enter image description here

I have no idea why it is doing this. And it is honestly the most bizarre thing I've ever encountered in tex.

What is happening here?

0
3

enter image description here

\documentclass{article}
\usepackage{array}
\begin{document}

\begin{tabular}{c | c | c | c | c}
 & Front & \multicolumn{2}{c|}{Center} & Back \\
\hline
Close
  & \multicolumn{2}{c|}{i}
  & \multicolumn{2}{c|}{u} \\
\hline
Mid
  & e
  & \multicolumn{2}{c|}{o} \\
\hline
A&B&C&D&E
\end{tabular}
\end{document}

At the primitive level tabular is an \halign construct and \halign has some unfortunate "optimisations" notably here if a column template is not used (due to being spanned in each row) that column is essentially dropped before column widths are allocated.

That happens here to column 3. If you put in a full row at the end then you get a more understandable output.

(A simple workaround is to delete the ABCD but leave in the blank row then compensate with a negative vertical space after the tabular.)

Compare with this table which has a full last row and more or less teh column layout that you got

enter image description here

\documentclass{article}
\usepackage{array}
\begin{document}

\begin{tabular}{c | c | c| c | c}
 & \multicolumn{2}{c|}{Front} & Center & Back \\
\hline
Close
  & i
  & \multicolumn{3}{c|}{u} \\
\hline
Mid
  & \multicolumn{2}{c|}{e}
  & o \\
\hline
A&B&C&D&E
\end{tabular}
\end{document}

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.