# Non-trivial table in LaTeX

I want to convert this OO table into latex:

This is what I have so far:

\begin{table}
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|} %p{4cm}
\hline
\multicolumn{7}{|c|}{Czas wykrycia} \\ \hline
Wymagania & Architektura & Programowanie & Testy & Po dostarczeniu  \\ \hline

\end{tabular}
\caption{.}
\end{center}
\end{table}


I don't understand why multicolumn is not centered and wide. This is my output:

-
You need to add the missing & & in the end of the row. You can't skip them even if they are empty. Also remove the empty line. –  percusse Aug 27 '12 at 20:36

Here's a starting point for you

Note that as @percusse said in his comment, you need to use alignment tabs even for columns that are empty. I've made use of the \cline command which stands for column line and has syntax

\cline{startingcolumn-endingcolumn}


so for example, \cline{2-7} draws a line from the 2nd column to the 7th column.

I've also loaded the geometry package just to enlarge the page size- you'll want to make sure it can fit inside your document.

For further reading, you might like to look at

• multirow package which would help with spanning across multiple rows
• caption to get rid of the : when your caption is empty (and also helps to customize captions globally)
• booktabs to help make beautiful tables. A lot of folks would recommend omitting the vertical lines, but I'll leave that up to you

MWE:

\documentclass{article}
\usepackage{geometry}

\begin{document}

\begin{table}
\centering
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{Koszt naprawy}             &\multicolumn{5}{|c|}{Czas wykrycia} \\ \cline{3-7}
\multicolumn{2}{|c|}{}                          & Wymagania     & Architektura  & Programowanie & Testy     & Po dostarczeniu  \\ \hline
Czas Wystapienia            &   Wymagania       &   1x          &   3x          &   5-10x       &   10x     &   10-100x \\\cline{2-7}
&   Architektura    &   -           &   1x          &   10x         &   15x     &   25-100x \\\cline{2-7}
&   Programowanie   & -             &   -           &   1x          &   10x     &   10-25x  \\\hline
\end{tabular}
\caption{.}
\end{table}

\end{document}

-

For comparison, the natural tables mechanism of ConTeXt is very well suited for such tables (with spanning rows and columns). For example, the above table can be typeset as:

\starttext
\bTABLE[align=middle, width=fit]
\bTR
\bTD[nx=2, ny=2] Koszt naprawy \eTD
\bTD[nx=5]       Czas wykrycia \eTD
\eTR

\bTR
\bTD Wymagania        \eTD
\bTD Architektura     \eTD
\bTD Programowanie    \eTD
\bTD Testy            \eTD
\bTD Po dostarczeniu  \eTD
\eTR

\bTR
\bTD[ny=3] Czas Wystapienia \eTD
\bTD Wymagania              \eTD
\bTD 1x                     \eTD
\bTD 3x                     \eTD
\bTD 5-10x                  \eTD
\bTD 10x                    \eTD
\bTD 10-100x                \eTD
\eTR

\bTR
\bTD   Architektura    \eTD
\bTD   -               \eTD
\bTD   1x              \eTD
\bTD   10x             \eTD
\bTD   15x             \eTD
\bTD   25-100x         \eTD
\eTR

\bTR
\bTD Programowanie   \eTD
\bTD -               \eTD
\bTD -               \eTD
\bTD 1x              \eTD
\bTD 10x             \eTD
\bTD 10-25x          \eTD
\eTR
\eTABLE
\stoptext


which gives

-
cool, nice demo! –  cmhughes Sep 1 '12 at 17:18