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'm trying to create a table which looks like

this

but I'm not really sure how to incorporate multiple spanning rows and columns together (to add 'Organism 1' and 'Organism 2'). I've gotten to this point so far:


\documentclass[a4paper,10pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}

\begin{document}
\begin{tabular}{r|c|c|}
\multicolumn{1}{r}{}
 &  \multicolumn{1}{c}{$S$}
 & \multicolumn{1}{c}{$T$} \\
\cline{2-3}
$S$ & $a,a$ & $b,c$ \\
\cline{2-3}
$T$ & $c,b$ & $d,d$ \\
\cline{2-3}
\end{tabular}

\end{document}

And it currently looks like this:

column spanning table

Can anyone suggest how to add the top 'Organism 2' and left 'Organism 1' row/column entries?

thanks!

share|improve this question
    
Welcome to tex.sx! I added your picture inline, which is preferable to links to pictures. –  Seamus Feb 24 '11 at 13:11
    
Thanks Seamus! I initially tried adding the images inline but I couldn't as I needed a minimum of 10 points. BTW, could you please embed the first image too (in the first line)? –  Nishant Feb 24 '11 at 13:20
1  
@Seasmus,@Nishant: I did included the first image now. The in-text reference was not correct. –  Martin Scharrer Feb 24 '11 at 13:40
add comment

1 Answer 1

up vote 5 down vote accepted

starting from your code, I got to this:

enter image description here

Basically, I have added the package multirow and changed the cline indexes.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{multirow}

\begin{document}
\begin{tabular}{cr|c|c|}
  \multicolumn{2}{r}{} & \multicolumn{2}{c}{Organism 2} \\

  \multicolumn{2}{r}{}
 & \multicolumn{1}{c}{$S$}
 & \multicolumn{1}{c}{$T$} \\

  \cline{3-4}


  \multirow{2}{*}{Organism 1} & $S$ & $a,a$ & $b,c$ \\
  \cline{3-4}

 & $T$ & $c,b$ & $d,d$ \\
  \cline{3-4}
\end{tabular}

\end{document}
share|improve this answer
    
Wow perfect! Thanks! –  Nishant Feb 24 '11 at 15:05
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.