Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to convert this OO table into latex:enter image description here

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: enter image description here

share|improve this question
3  
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
add comment

2 Answers 2

up vote 15 down vote accepted

Here's a starting point for you

screenshot

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}
share|improve this answer
add comment

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

enter image description here

share|improve this answer
    
cool, nice demo! –  cmhughes Sep 1 '12 at 17:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.