# How to create a complex table?

Since I have only little experience in Latex, I'm not sure how to create a specific table as shown in the example screenshot. Is such a table even possible with Latex and if yes, where do I need to start? Or is the layout maybe not the best choice and I should setup the layout of the table in another way?

-
Is the table part of a form and to be filled out manually or are the values simply missing? A form might need more space for individual entries and lines to where to put entries. In that case you might not need the horizontal lines dividing Quality, Time, and Costs but vertical space is sufficient. –  Christian Lindig Jan 4 '13 at 11:19
the values are simply missing but the values are quite short (+, -, =) –  Airlike Jan 4 '13 at 13:34

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}
\multirow{3}{*}{Quality} & A  \\
& B  \\
& C  \\
\multirow{3}{*}{Time}    & A  \\
& B  \\
& C  \\
\multirow{3}{*}{Costs}   & A  \\
& B  \\
& C  \\
\bottomrule
\end{tabular*}

\end{document}


Output

-
Please do not post code without explanation. –  Marc van Dongen Jan 4 '13 at 14:23
@MarcvanDongen I added an explanation, thanks for the advise. –  xfoo Jan 4 '13 at 14:47

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.
-
thanks for providing the code! I'll with test both answers which provided code - the output seems to be same! appreciate your help –  Airlike Jan 4 '13 at 13:20