# multicolumn table

I want to make a latex multicolumn table, i wrote the code below, however, the result is not what I want. Is there anything wrong? Anyone can help? Thanks in advance.

## The code:

\usepackage{booktabs}
\usepackage{multirow}
\usepackage{siunitx}
...
\begin{table}
\begin{tabular}{lrrrr}
\toprule
\multicolumn{2}{c}{Avg. FPS} \\
\cmidrule(r){4-5}
Models & Tris (M) & Resolution & moving & static \\
\midrule
Model 1 & 5 & 1024*1024 & 40 & 60 \\
Model 2 & 12 & 1024*1024 & 40 & 60 \\
Model 3 & 73 & 1024*1024 & 40 & 40 \\
Model 4 & 337 & 1024*1024 & 20 & 30 \\
\bottomrule
\end{tabular}
\end{table}


## The result:

What i want:

• you want &&& before the \multicolumn to get into the correct column and you want c not r for the 3rd column – David Carlisle Oct 12 '14 at 19:33

I would like to suggest that you not use the multirow package. Instead, place all level-1 information in the first row of header.

I would also like to suggest that you use S[table-format=3.0] instead r for the second column. Columns 3 to 5 will look better if you use columns of type c. You may also want to replace the * multiplicative symbol with the more prominent \times symbol; you could write 1024$\times$1024, as is done in the code below, or you could write \num{1024x1024} (egreg's suggestion -- many thanks!), where \num is a macro provided by the siunitx package.. If you choose the latter input method, you may also want provide the instruction \sisetup{tight-spacing=true} in the preamble in order to avoid having a lot of whitespace around the \times symbols.

Separately, I think you should also consider getting rid of the whitespace to the left of the first column and to the right of the final column. The resulting look is shown in the second example below.

\documentclass{article}
\usepackage{booktabs,siunitx}
\begin{document}
\begin{table}
\centering
\begin{tabular}{ l S[table-format=3.0] c c c }
\toprule
Models & {Tris (M)} & Resolution &\multicolumn{2}{c}{Avg.\ FPS} \\
\cmidrule(l){4-5}
&&& moving & static \\
\midrule
Model 1 &   5 & 1024$\times$1024 & 40 & 60 \\
Model 2 &  12 & 1024$\times$1024 & 40 & 60 \\
Model 3 &  73 & 1024$\times$1024 & 40 & 40 \\
Model 4 & 337 & 1024$\times$1024 & 20 & 30 \\
\bottomrule
\end{tabular}

%% now, without whitespace to the left of first col and to the right of final col
\bigskip
\begin{tabular}{@{} l S[table-format=3.0] c c c @{}}
\toprule
Models & {Tris (M)} & Resolution &\multicolumn{2}{c}{Avg.\ FPS} \\
\cmidrule(l){4-5}
&&& moving & static \\
\midrule
Model 1 &   5 & 1024$\times$1024 & 40 & 60 \\
Model 2 &  12 & 1024$\times$1024 & 40 & 60 \\
Model 3 &  73 & 1024$\times$1024 & 40 & 40 \\
Model 4 & 337 & 1024$\times$1024 & 20 & 30 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

• You might input the entries in the third column as \num{1024x1024} – egreg Oct 12 '14 at 21:02
• @egreg - Thanks for this. I've added your suggestion to the list of possibilities, along with a suggestion to provide the instruction \sisetup{tight-spacing=true} in the preamble to maintain nice-and-tight spacing around the \times symbols. – Mico Oct 12 '14 at 21:30

You can use \usepackage{multirow} and \usepackage{multicol} and the line

Models & {Tris (M)} & Resolution &\multicolumn{2}{c}{Avg.\ FPS}


could be rewritten as

\multirow{2}{*}{Models} &  \multirow{2}{*} {Tris (M)} &   \multirow{2}{*}{Resolution} &\multicolumn{2}{c}{Avg.\ FPS} \\


so as to center the first three column headings. You will be getting the result as shown below

• You should post a full MWE rather than unformatted code snippets. Observe that because of the presence of \cmidrule, the \multirow{2}{*}{...} instructions produce rather unsatisfactory vertical centering. Finally, note that the multicol package is irrelevant in this context and need not be loaded. – Mico Oct 13 '14 at 5:04