[Tex/LaTex] How to create table with inner columns inside larger columns

columnsmulticolumntables

I want to create this kind of table with 3 large columns and at one point the column is divided to two smaller columns. Please note that the column not divided in the whole space.

How can create the table with custom column sizes inside the larger columns?

|------------------------------------------------------------|
|                |          A          |       Most Mon      |
-------------------------------------------------------------|
|  Methods       | Time [s] | RunCount | Time [s] | RunCount |
|----------------|---------------------|---------------------|
|    C           |          |          |    4     |    1     |
|    D           |          |          |    5     |    2     |
|    E           |          |          |    6     |    3     |
-------------------------------------------------------------|

Best Answer

Actually, it's the other way round; initially you declare 5 columns and, in the first row, using \multicolumn you span some cells to occupy to of them.

In the following example, the packages siunitx and booktabs were used to improve the table formatting:

\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}

\begin{document}

\noindent\begin{tabular}{lSSSS}
\toprule
& \multicolumn{2}{c}{A} & \multicolumn{2}{c}{Most Mon} \\
\cmidrule(r){2-3}\cmidrule(l){4-5}
Methods & {Time [\si{\second}]} & {RunCount}  & {Time [\si{\second}]} & {RunCount} \\
\midrule
C & 12.3 & 5 & 34.6 & 7 \\
D & 1.35 & 5 & 4.93 & 7 \\
\bottomrule
\end{tabular}

\end{document}

enter image description here

Of course, instead of S you could use any other column type (and deal with possible alignments in other ways) such as c, l, r, or p{<length>}.

In a comment it has been requested to produce the table with the vertical rules; here it is:

\documentclass{article}
\usepackage{siunitx}

\begin{document}

\noindent\begin{tabular}{| l | S | S | S | S |}
\cline{2-5}
\multicolumn{1}{c|}{}& \multicolumn{2}{c|}{A} & \multicolumn{2}{c|}{Most Mon} \\
\hline
Methods & {Time [\si{\second}]} & {RunCount}  & {Time [\si{\second}]} & {RunCount} \\
\hline
C & 12.3 & 5 & 34.6 & 7 \\
D & 1.35 & 5 & 4.93 & 7 \\
\hline
\end{tabular}

\end{document}

enter image description here