# merging table rows not working

I've created a LaTeX table (using tabular)

\documentclass{article}
\begin{document}
\begin{tabular}{   c |  c  | c    | c| c  }
1 & 2 & 3 &4 & 5\\
6 & 7 & 8 &9&10\\
\end{tabular}
\end{document}


but am having a few problems:

• there is no vertical line between Heading 2 and Heading 3
• the alignment in the 2nd and 3rd column is not centered under 'Heading 2' (and the 4th and 5th column under 'Heading 3')
• the width of the 2nd and 3rd columns (and 4th and 5th) is not equal

Why is this? Any help with this would be great.

• This is the intended behavior. The multicolumn definition has its own column specification which overrides the table specification for that row. Write \multicolumn{2}{|c|}{Heading 2} to get a vertical line between the headings 2 and 3. – Harald Dec 3 '14 at 15:15
• You can find some tips on good styling of tabular material in the documentation of package booktabs. – Johannes_B Dec 3 '14 at 15:17

You need c| to put the rule back at the end of the spanning entry.

Harder is the centering. If a spanning cell is wider than the cells it spans, all excess width goes in the last column spanned.

One way to avoid that is to make the columns naturally wider, here I use dcolumn and padding them as if of the form 1234.123 the alignment also makes 10 and 5 line up possibly correctly.

\documentclass{article}
\usepackage{dcolumn}
\newcolumntype{d}{D{.}{.}{4.3}}
\begin{document}
\begin{tabular}{   d |  d  | d    | d| d  }

• Thank you, this works. It would be nice if the columns could be automatically be re-sized (without the need for dcolumn but this works for now. – James Dec 9 '14 at 9:54