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:Two options: you can change to centered
p{...}
columns (the two options show this same approach with and without thetabularx
package):Not related to the question: inside a float is better to use
\centering
and not thecenter
environment; the later adds extra vertical space which most of the times is undesired.