# Tables with labeled lines

I have a little question concerning the layout of tables. Does LaTeX provide a way to create tables like shown in the picture below?

I am referring to the two axes of the table that are labeled "K" and "n". Is there a way to have labeled axes in a table (with a little arrow at the end) instead of just having normal vertical and horizontal lines? Can I use the tabular environment or do I have to use something fancier?

Here is how my table would look without labeled axes:

\documentclass{scrartcl}

\begin{document}
\begin{tabular}{l|cccc}
& 0 & 1 & 2 & 3 \\ \hline
$k_1 = 3$ & O & - & - & I \\
$k_2 = 4$ & O & - & - & O \\
\end{tabular}
\end{document}


Btw, does anybody know what those characters in the table in the screen caption above are? I approximated them with "I" and "O" but it doesn't look quite right.

I would be grateful for any help (and excuse my English, it's not my native tongue)!

A common tabular environment seems not appropriate for this kind of table. This is an approach with »PGF/TikZ« that draws a matrix with arrows between nodes where desired.

\documentclass[11pt,border=2pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{selinput}
\SelectInputMappings{
germandbls={ß}
}
\usepackage{tikz}
\usetikzlibrary{calc,matrix,shapes.callouts}

\begin{document}
\begin{tikzpicture}[
thick,
>=stealth,
matrix of math nodes/.append style={execute at begin cell=\strut},
note/.style={
rounded corners,
rectangle callout,
inner sep=6pt,
fill=#1,
callout relative pointer={(-0.5,0.5)},
font=\huge
}
]
\matrix (table) [
matrix of math nodes,
nodes in empty cells,
nodes={
anchor=center,
inner sep=6pt,
outer sep=0pt,
minimum size=1.5em,
}
] {
~~~~~~~~~ & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 & 16 \\
k_1=2     & \bigcirc & - & | & - & - & - & - & - & - & - & - & - & - & - & - & - & - \\
&   &   &   &   &   &   &   &   &   &   &    &    &    &    &    &    &    \\
k_2=3_1   & \bigcirc & - & \bigcirc & | & - & | & - & - & - & - & - & - & - & - & - & - & - \\
&   &   &   &   &   &   &   &   &   &   &    &    &    &    &    &    &    \\
k_3=3_2   & \bigcirc & - & \bigcirc &   &   &   &   &   &   &   &    &    &    &    &    &    &    \\
&   &   &   &   &   &   &   &   &   &   &    &    &    &    &    &    &    \\
k_4=5     &   &   &   &   &   &   &   &   &   &   &    &    &    &    &    &    &    \\
~~~~~~~~~ &   &   &   &   &   &   &   &   &   &   &    &    &    &    &    &    &    \\
};

\draw[->] (table-2-1.north west) -- ($(table-2-18.north east)+(1em,0)$) node[right,font=\Large] {$K$};
\draw[->] (table-1-1.north east) -- ($(table-9-1.south east)+(0,-1ex)$) node[below,font=\Large] {$n$};

\foreach \i [evaluate=\i as \j using int(\i+3)] in {5,6,...,15}
\draw[->] (table-2-\i.south) -- (table-4-\j.north);
\foreach \c  in {8,9,...,18}
\draw[->,dashed] (table-2-\c.south) -- (table-4-\c.north);
\foreach \c  in {2,3,4}
\draw[->,dashed] (table-4-\c.south) -- (table-6-\c.north);

\node[note=blue!25,above left=1cm] at (table.south east) {Restliche Einträge analog \ldots};
\end{tikzpicture}
\end{document}


I recommend to take a look at the user guide to get familiar with that package.

Regarding the symbols it's not entirely clear to me. I would interpret "O" as some kind of circle and the "I" as the pipe symbol ("|").

• This is just... amazing! What a great answer! You even recreated the diagonal arrows... Thanks so much for your help! One question... what do I have to do if I want to add more coloumns or rows? I tried it and got an error. – Ariadne Nov 24 '13 at 14:24
• @Ariadne: That's actually done in the same way as in tabular. Here you need to append columns and rows inside the \matrix. Note that you need to adapt the two long arrows after that. – Thorsten Donig Nov 24 '13 at 17:18