I want to create the table as is shown in the following picture.
Could you please help me?
[Tex/LaTex] Table with 2 columns and 3 subcolumns
multicolumntables
Related Solutions
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}
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}
Here is a start for you.
With \usepackage{rotating
und sidewasytable
and not landscape.
\documentclass[a4paper]{article}
\usepackage{pdflscape,array,booktabs}
\setlength\tabcolsep{5pt}
\usepackage{rotating}
\begin{document}
\begin{sidewaystable}
\caption{Simulation results}
\begin{tabular}{>{\raggedright}p{2.2cm}lcccccccccccc}
\hline
& \multicolumn{2}{c}{Settings} & \multicolumn{10}{c}{Analysis} \\
\cline{2-3} \cline{5-13}
Model & $\beta$ & n & & PERFECT & CC & NO-T & LOGT & T & T2 & NA & COX & COX*\\
\midrule
\multicolumn{13}{l}{Bias} \\
Base case*& 0 & 336 & & 0.00 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 \\
& 0 & 336 & & 0.00 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 \\
& 0 & 336 & & 0.00 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 \\
Shape 2& 0 & 336 & & 0.00 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 \\
Admin cens 2& 0 & 336 & & 0.00 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 \\\multicolumn{13}{l}{} \\
\multicolumn{13}{l}{Per cent error in model standard error} \\
Base case& 0 & 336 & & 0.00 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 \\
& 0 & 336 & & 0.00 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 \\
& 0 & 336 & & 0.00 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 \\
Shape 2& 0 & 336 & & 0.00 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 \\
Admin cens 2& 0 & 336 & & 0.00 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 \\
\multicolumn{13}{l}{} \\
\multicolumn{13}{l}{Power} \\
Base case& 0 & 336 & & 0.00 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 \\
& 0 & 336 & & 0.00 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 \\
Shape 2& 0 & 336 & & 0.00 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 \\
admin cens& 0 & 336 & & 0.00 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 & -0.01 \\
\bottomrule
\multicolumn{13}{l}{*Base case: ...} \\
\end{tabular}
\end{sidewaystable}
\end{document}
Best Answer
This is one way to do it:
I suggest you to look up on the LaTeX Wikibook when you need some general information. For any particular package you use, always read its documentation on the CTAN. A very handy general reference is Stefan Kottwitz's LaTeX Cookbook. It's not gratis, however, Packt often make some deals, so keep an eye on their site if you wish.