# Creating tables with spanning rows/columns

I'm trying to create a table which looks like

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:

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

thanks!

-
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
@Seasmus,@Nishant: I did included the first image now. The in-text reference was not correct. – Martin Scharrer Feb 24 '11 at 13:40

## 1 Answer

starting from your code, I got to this:

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}

-
Wow perfect! Thanks! – Nishant Feb 24 '11 at 15:05
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.7452681660652161, "perplexity": 1838.0106582309231}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": false}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2016-07/segments/1454701147492.21/warc/CC-MAIN-20160205193907-00093-ip-10-236-182-209.ec2.internal.warc.gz"}