TransWikia.com

How to merge columns in a table?

TeX - LaTeX Asked by BrettHarry on April 18, 2021

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}

2 Answers

This can be done using multicolumn:

multicolumn{<no of columns>}{<column alignment>}{<content>}

As an example, 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

Correct answer by Stefan Kottwitz on April 18, 2021

multicolumn{<no of columns>}{<column type>}{<stuff>}

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

Answered by user2478 on April 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP