# How could I create a diagram that looks like this?

I am trying to create a diagram for a document that illustrates a table. (Below is an example of how I would like it to look.) What tools should I use to replicate this?

-
Welcome to TeX.sx! On this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Questions that look like "Please do this complicated thing for me" tend to get closed because they are "too localized". Please try to make your question clear and simple by giving a minimal working example (MWE): you'll stand a greater chance of getting help. –  hpesoj626 Oct 22 '12 at 2:23

One possibility using TikZ:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart,positioning}

\begin{document}

\begin{tikzpicture}[my shape/.style={
rectangle split, rectangle split parts=#1,draw,
rectangle split empty part height= 1.5ex,align=center}]

% the rectangular nodes
\node[my shape=7] (rec1) {\phantom{10}};
\node[right = 15pt of rec1,my shape=2] (rec2) at (rec1.three split east) {16\nodepart{two}17};
\node[right = 15pt of rec1,my shape=2] (rec3) at (rec1.six split east) {12\nodepart{two}13};
\node[right = 4cm of rec1,my shape=7] (rec4) {\nodepart{two}17\nodepart{three}26\nodepart{four}16\nodepart{five}\nodepart{six}12\nodepart{seven}13};
\node[right = 15pt of rec3,my shape=1] (rec5) at (rec3.text east) {26};

% the numbers to the left of the rectangles
\foreach \part [count=\i from 0] in {text ,two ,three ,four ,five ,six ,seven }
{
\foreach \rect in {rec1,rec4}
\node[label=left:$\i$] at (\rect.\part west) {};
}

% the arrows
\draw[->] (rec1.three east) -- (rec2.text west);
\draw[->] (rec1.four east) -- (rec2.two west);
\draw[->] (rec1.six east) -- (rec3.text west);
\draw[->] (rec1.seven east) -- (rec3.two west);
\draw[->] (rec3.text east) -- (rec5.text west);
\end{tikzpicture}

\end{document}


-
This is spot on! Thank you very much for the help. –  user41419 Oct 22 '12 at 4:21

Without Tikz ...

\documentclass{article}
\begin{document}

\begin{minipage}{0.4\linewidth}
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{c|c| *2{@{}c@{}|c|} }
\cline{2-2}
0 & \phantom{0} & \multicolumn{4}{c}{}                    \\ \cline{2-2}
1 &             & \multicolumn{4}{c}{}                    \\ \cline{2-2} \cline{4-4}
2 &             & $\rightarrow$ & 16                      \\ \cline{2-2} \cline{4-4}
3 &             & $\rightarrow$ & 17                      \\ \cline{2-2} \cline{4-4}
4 &             & \multicolumn{4}{c}{}                    \\ \cline{2-2} \cline{4-4} \cline{6-6}
5 &             & $\rightarrow$ & 12 & $\rightarrow$ & 26 \\ \cline{2-2} \cline{4-4} \cline{6-6}
6 &             & $\rightarrow$ & 13                      \\ \cline{2-2} \cline{4-4}
\end{tabular}
\end{minipage}%
\begin{minipage}{0.4\linewidth}
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{c|c|}
\cline{2-2}
0 &    \\ \cline{2-2}
1 & 17 \\ \cline{2-2}
2 & 26 \\ \cline{2-2}
3 & 16 \\ \cline{2-2}
4 &    \\ \cline{2-2}
5 & 12 \\ \cline{2-2}
6 & 13 \\ \cline{2-2}
\end{tabular}
\end{minipage}

\end{document}


which gives,

My attempt to simplify the first tabular failed :(

\begingroup
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{c|c|@{$\rightarrow$}|c|@{$\rightarrow$}|c|}
\cline{2-2}
0 & \phantom{0}             \\ \cline{2-2}
1 &                         \\ \cline{2-3}
2 &             & 16        \\ \cline{2-3}
3 &             & 17        \\ \cline{2-3}
4 &                         \\ \cline{2-4}
5 &             & 12 & 26   \\ \cline{2-4}
6 &             & 13        \\ \cline{2-3}
\end{tabular}
\endgroup


This produces,

I don't know if there is a way to get rid of those horizontal rules above and below the rightarrow. I thought of using the hhline package but that is not meant of this. If someone knows how to do it, I would really appreciate a reply.

-