# How to merge columns in a table?

I have this table, but wanted to format the first row. I like to match the two columns of first row, and last two columns of the same first row. Any suggestion on how to do that?

\begin{table}[!h]
\caption{Comparison of percentages.}
\begin{tabular}{lclclclclc}
\hline
\hline
Mode &  Var  &  Cum\\
\hline
{}       & EF   & CHF    & EF2   & CHF2\\
1   &  17.5 & 19.1   & 17.5  & 19.1\\
2   &  11.8 & 12.7   & 29.3  &  31.9\\
3   &  6.6  &  5.6         & 35.9    &  37.4\\
\hline
\end{tabular}
\end{table}

-
indent your code blocks with four spaces to have them pretty print. Or select the text and click the {} button. –  Seamus Jul 12 '11 at 11:11
Have a look at LaTeX table capabilities, there are examples with code, output and explanation. –  Stefan Kottwitz Jul 12 '11 at 11:33
@Stefan Kottwitz: Thanks! I always wondered how to make a good formating on these pages. Yes, I have seen some amazing stuff at the link. Cheers! –  BrettHarry Jul 12 '11 at 11:54
@Seamus: Thanks! –  BrettHarry Jul 12 '11 at 18:45

An example, how it can be done using \multicolum, with some improvements using booktabs:

\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
\setlength{\heavyrulewidth}{1.5pt}
\setlength{\abovetopsep}{4pt}
\begin{document}
\begin{table}[!htbp]
\centering
\caption{Comparison of percentages.}
\begin{tabular}{*5c}
\toprule
Mode &  \multicolumn{2}{c}{Var} & \multicolumn{2}{c}{Cum}\\
\midrule
{}   & EF   & CHF    & EF2   & CHF2\\
1   &  17.5 & 19.1   & 17.5  & 19.1\\
2   &  11.8 & 12.7   & 29.3  & 31.9\\
3   &  6.6  &  5.6   & 35.9  & 37.4\\
\bottomrule
\end{tabular}
\end{table}
\end{document}


-
@ Stefan Kottwitz: Thank you very much! This is amazing! Is it possible to shift the Mode back to first column and Var on top of 2nd/3rd columns? –  BrettHarry Jul 12 '11 at 11:58
@BrettHarry: no problem, just apply \multicolumn to Var instead, I modified the example. –  Stefan Kottwitz Jul 12 '11 at 12:32
I'm grateful! I was just about to finish typesetting my thesis and this is very helpful with the dateline!!!! –  BrettHarry Jul 12 '11 at 12:37
@BrettHarry: We are happy to help. Feel free to post further questions, if you think the thesis typesetting might be improved a bit before submitting it. –  Stefan Kottwitz Jul 12 '11 at 12:44
@BrettHarry Mori's paper and booktabs documentation can help you design good tables. –  pmav99 Jul 12 '11 at 16:07
\multicolumn{<no of columns>}{<column type>}{<stuff>}


there are a lot of examples if you search for this topic

-
Thanks Herbert! –  BrettHarry Jul 12 '11 at 11:54