# Table with equal columns

I need a table with 4 rows, 3 columns and a partial horizontal line in column 2-3. I tried:

\documentclass{article}

\begin{document}

\begin{table}
{
\begin{center}
\begin{tabular}{|c|c|c|}
\hline
Col 1 & \multicolumn{2}{|c|}{Col 2-3 Heading}\\
\cline{2-3} & Col 2 & Col 3\\
\hline
- & - & -\\
\hline
- & - & - \\
\hline
- & - & - \\
\hline
\end{tabular}
\end{center}
}
\end{table}

\end{document}


which yielded:

Note that, width of column 2 & 3 are not equal. How can I fix that?

-

If the width of the contents of a spanned cell produced using \multicolumn is larger then the width of the contents of the individual cells, the extra space is added to the last spanned column, as you have experienced and this example shows even clearer:

\documentclass{article}

\begin{document}

\noindent\begin{tabular}{|c|c|c|c|}
\hline
A & \multicolumn{3}{c|}{Some text just for the example} \\
\hline
B & C & D & E \\
\hline
\end{tabular}

\end{document}


Two options: you can change to centered p{...} columns (the two options show this same approach with and without the tabularx package):

\documentclass{article}
\usepackage{tabularx}

\newcolumntype{C}{>{\centering\arraybackslash}p{1.5cm}}
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\begin{document}

\begin{table}
\centering
\begin{tabular}{|c|c|c|}
\hline
Col 1 & \multicolumn{2}{c|}{Col 2-3 Heading}\\
\cline{2-3} & Col 2 & Col 3\\
\hline
- & - & -\\
\hline
- & - & - \\
\hline
- & - & - \\
\hline
\end{tabular}
\end{table}

\begin{table}
\centering
\begin{tabular}{|C|C|C|}
\hline
Col 1 & \multicolumn{2}{c|}{Col 2-3 Heading}\\
\cline{2-3} & Col 2 & Col 3\\
\hline
- & - & -\\
\hline
- & - & - \\
\hline
- & - & - \\
\hline
\end{tabular}
\end{table}

\begin{table}
\centering
\begin{tabularx}{6cm}{|Y|Y|Y|}
\hline
Col 1 & \multicolumn{2}{c|}{Col 2-3 Heading}\\
\cline{2-3} & Col 2 & Col 3\\
\hline
- & - & -\\
\hline
- & - & - \\
\hline
- & - & - \\
\hline
\end{tabularx}
\end{table}

\end{document}


Not related to the question: inside a float is better to use \centering and not the center environment; the later adds extra vertical space which most of the times is undesired.

-
It worked, but can you explain why is this happening? – pushpen.paul Mar 15 '14 at 19:26
@pushpen.paul yes, it's a well known phenomenon. I'll add the explanation in some minutes (lunch time here). – Gonzalo Medina Mar 15 '14 at 19:27
@pushpen.paul explanation added. – Gonzalo Medina Mar 15 '14 at 19:35