How to create a complex table?
A great place to start, when you don't know how to do a table (or something else in LaTeX
) is wikibooks.
In the following I'll use the packages booktabs
and multirow
for they allow me to insert specific rules and cell entries spanning more then one row/column. As your example uses a sans-serif font, I used \renewcommand*\familydefault{\sfdefault}
to reproduce this.
The tabular*
environment allows to set a specific width, in this case \linewidth
; a sidenote, for larger tables you could switch to landscape
-mode.
For more information concerning tables, check out the wikibooks link.
Now here how you could realize the table you want in LaTeX
.
Code
\documentclass{article}
\usepackage{booktabs}
\usepackage{multirow}
\renewcommand*\familydefault{\sfdefault}
\begin{document}
\begin{tabular*}{\linewidth}{ @{\extracolsep{\fill}} ll *{13}c @{}}
\toprule
Measures & Task & \multicolumn{4}{c}{Method1} &
\multicolumn{4}{c}{Method2} & \multicolumn{4}{c}{Method3} & p-value \\
\midrule \midrule \addlinespace \\
& & 1 & 2 & 3 & 4 & 1 & 2 & 3 & 4 & 1 & 2 & 3 & 4 & \\
\cmidrule{3-6} \cmidrule{7-10} \cmidrule{11-14} \cmidrule{15-15}
\addlinespace \\
\multirow{3}{*}{Quality} & A \\
& B \\
& C \\
\midrule \addlinespace \\
\multirow{3}{*}{Time} & A \\
& B \\
& C \\
\midrule \addlinespace \\
\multirow{3}{*}{Costs} & A \\
& B \\
& C \\
\bottomrule
\end{tabular*}
\end{document}
Output
Here is the table:
Here is the code to typeset the table:
\begin{tabular}{@{}lllllllllllllllll@{}} \toprule Measures & Task &\multicolumn{4}{c}{Method1} & & \multicolumn{4}{c}{Method2} & &\multicolumn{4}{c}{Method3} & p-value \\ \midrule && 1 & 2 & 3 & 4 & & 1 & 2 & 3 & 4 & & 1 & 2 & 3 & 4 & \\ \cmidrule{3-6} \cmidrule{8-11} \cmidrule{13-16} \multirow{3}{*}{Quality} & A \\ & B \\ & C \\ \midrule \multirow{3}{*}{Time} & A \\ & B \\ & C \\ \midrule \multirow{3}{*}{Cost} & A \\ & B \\ & C \\ \bottomrule \end{tabular} \end{document}
Some explanations:
Use
booktabs
package to get better row spacing and rules. Note the different use of\toprule
,\bottomrule
and\midrule
.Let an empty column between the columns that have a partial rule
\cmidrule
.- In the column specification use
@{}
at the beginning and end. In this way the rules are not longer than the table itself. - Use the package
multirow
to center in multiple rows. - Don't use double rules.