Typesetting special table formats

I want to typeset Flynn’s taxonomy:

         | Single      | Multiple
| instruction | instructions
---------+-------------+--------------
Single   |             |
data     |    SISD     |    MISD
---------+-------------+--------------
Multiple |             |
data     |    SIMD     |    MIMD


using LaTeX (tables?). Alas, my attempts at consistent spacing fail abysmally.

% Requires package sideways.
\begin{tabular}{cc|c|c}
& & Single & Multiple \\
& & instruction & instructions \\
\hline
\begin{sideways}Single\end{sideways} & \begin{sideways}data\end{sideways} & SISD & MISD \\
\hline
\begin{sideways}Multiple\end{sideways} & \begin{sideways}data\end{sideways} & SIMD & MIMD
\end{tabular}


Ideally, I would like for all four quadrants to be the same size, and (of course) the text to be centered. Also, the table headers should have some semblance of coherent layout (equal spacing, height of top headers equal to width of side headers). But all I get is this:

Which has, in summary:

• No centered left headers
• Too large spacing in left headers
• No vertically centered content
• Non-square table cells for the four main content cells.

What’s the best way of doing this in LaTeX? I feel that TikZ would be an inexcusable overkill but I don’t know how to do it even there and I’d be obliged for any hints.

-
Rotated labels are hard to read. In this case they are very short and can easily remain in normal left-to-right orientation. – sastanin Nov 26 '10 at 0:39
@jet: I agree. It seemed like a good idea on paper. – Konrad Rudolph Nov 26 '10 at 8:23

2 Answers

This is only a first approach and might need some final tweaks.

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{rotating}
\usepackage{array}

\newcolumntype{M}{>{\centering\arraybackslash}m{2cm}}

\begin{document}
\begin{tabular}{M|M|M}
& Single & Multiple \\
& instruction & instructions \\ \hline
\begin{sideways}\parbox{2cm}{\centering Single data}\end{sideways} & SISD & MISD \\ \hline
\begin{sideways}\parbox{2cm}{\centering Multiple data}\end{sideways} & SIMD & MIMD
\end{tabular}
\end{document}

-
By setting the left column style separately (to assign a different width) and removing the spacing before and after (@{}R@{}) I got the header on the left to be symmetrical to the header on top. But I think I’ll ultimately forego the sideways rotation anyway to make it more readable. – Konrad Rudolph Nov 26 '10 at 10:21
I, like Caramdir, think that a picture adds to the value of the answer. It’s far from obvious how this code is rendered. – Konrad Rudolph Nov 28 '10 at 14:49

A quick solution with TikZ (there are probably better ways to do this)

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}
\begin{tikzpicture}
\matrix (t) [matrix of nodes,align=center,nodes={text width=2cm}] {
|[text width=0cm]|                               & Single instruction       & Multiple instructions \\
|[rotate=90,minimum width=0cm]| {Single\\data}   &|[minimum size=2cm]| SISD & |[minimum size=2cm]|MISD \\
|[rotate=90,minimum width=0cm]| {Multiple\\data} &|[minimum size=2cm]| SIMD &|[minimum size=2cm]| MIMD \\
};
\draw (t-2-1.north east) -- (t-2-3.north east);
\draw (t-3-1.north east) -- (t-3-3.north east);
\draw (t-1-2.north west) -- (t-3-2.south west);
\draw (t-1-3.north west) -- (t-3-3.south west);
\end{tikzpicture}
\end{document}


-
I have no idea how to exactly center SISD, etc. (currently their baseline seems to be vertically centered). – Caramdir Nov 25 '10 at 21:48