Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
2  
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
3  
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

2 Answers 2

up vote 26 down vote accepted

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}

table with merged cells

share|improve this answer
    
@ 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
1  
@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
1  
@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
1  
@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

share|improve this answer
    
Thanks Herbert! –  BrettHarry Jul 12 '11 at 11:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.