[Tex/LaTex] Table with equal columns

tables

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?

Best Answer

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}

enter image description here

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}

enter image description here

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.