[Tex/LaTex] Dropped column in multicolumn table

multicolumntables

In a table with 4 rows and 4 columns I try to merge different cells in every row while preserving the table layout. As there are never more than 3 cells in a row, a table column seems to be dropped.

If I add an empty row containing 4 cells there are 4 columns. Question: is it possible to preserve all columns without adding an empty row? Thank you.

Here is my goal:

-------------------
| 1               |
-------------------
| 2          | 14 |
-------------------
| 3 | 7      | 15 |
-------------------
| 4 | 8 | 12      |
-------------------

And here, what I get:

 --------------
| 1          |
--------------
| 2     | 14 |
--------------
| 3 | 7 | 15 |
--------------
| 4 | 8 | 12 |
--------------

The code:

\documentclass[10pt]{article}
\usepackage{multicol}
\begin{document}

\section{A}
{\begin{tabular}{|l|l|l|l|}
  \hline \multicolumn{4}{|l|}{1} \\
  \hline \multicolumn{3}{|l|}{2} & 14 \\
  \hline 3 & \multicolumn{2}{|l|}{7} & 15 \\
  \hline 4 & 8 & \multicolumn{2}{|l|}{12} \\
  \hline
\end{tabular}}

\section{B}
{\begin{tabular}{|l|l|l|l|}
  \hline \multicolumn{4}{|l|}{1} \\
  \hline \multicolumn{3}{|l|}{2} & 14 \\
  \hline &   &   &   \\
  \hline 3 & \multicolumn{2}{|l|}{7} & 15 \\
  \hline 4 & 8 & \multicolumn{2}{|l|}{12} \\
  \hline
\end{tabular}}

\section{Goal}

I would like to have a table as in section B but without the third (empty) row.

\end{document}

Best Answer

The following is probably what you're after:

enter image description here

\documentclass[10pt]{article}
\begin{document}

\section{A}
\begin{tabular}{|l|l|l|l|}
  \hline \multicolumn{4}{|l|}{1} \\
  \hline \multicolumn{3}{|l|}{2} & 14 \\
  \hline 3 & \multicolumn{2}{|l|}{7} & 15 \\
  \hline 4 & 8 & \multicolumn{2}{|l|}{12} \\
  \hline
\end{tabular}

\section{B}
\begin{tabular}{|l|l|l|l|}
  & & \phantom{12} & \\[-\normalbaselineskip] % fake/empty row
  \hline \multicolumn{4}{|l|}{1} \\
  \hline \multicolumn{3}{|l|}{2} & 14 \\
  \hline 3 & \multicolumn{2}{|l|}{7} & 15 \\
  \hline 4 & 8 & \multicolumn{2}{|l|}{12} \\
  \hline
\end{tabular}

\section{Goal}

I would like to have a table as in section B but without the third (empty) row.

\end{document}​

The motivation behind this solution stems from what is commonly used in the tabbing environment where you specify the tabbing intervals and then \kill the row.

Note that you don't need multicol for this, since the default tabular is supported in LaTeX.