# Connecting tables using multipart

I'm trying to draw tables and connect them with arrows, as in the picture: I would like to use the "multipart nodes", since it is mentioned in a comment here that it is appropriate. However, it's really hard to get started. Would anyone mind giving even a simple example (or pointing me to one) of how to do something like this?

• You can connect ordinary tables, either by embedding them into a tikzpicture or by using tikzmark. However, you might want to provide us with an MWE that contains the tables without connections. – user194703 Feb 12 '20 at 18:15

## 1 Answer

You can use ordinary tabulars. Either embed them in a tikzpicture or use tikzmark. The following MWE illustrates both options.

\documentclass{article}
\usepackage{geometry}
\usepackage{tikz}
\usetikzlibrary{positioning,tikzmark}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[nodes={inner sep=0pt,outer sep=0pt},node distance=1cm and
2cm]
\node (A){\begin{tabular}{|C{3em}|C{3em}|}
\hline
A & B \\
\hline
u & v \\
x & y \\
\hline
\end{tabular}};
\node[below=of A] (B){\begin{tabular}{|C{3em}|C{3em}|}
\hline
A & B \\
\hline
u & v \\
x & y \\
\hline
\end{tabular}};
\node[below=of B] (C){\begin{tabular}{|C{3em}|C{3em}|}
\hline
A & B \\
\hline
u & v \\
x & y \\
\hline
\end{tabular}};
\node[right=of B] (D){\begin{tabular}{|C{3em}|C{3em}|}
\hline
A & B \\
\hline
u & v \\
x & y \\
\hline
\end{tabular}};
\node[right=of D] (E){\begin{tabular}{|C{3em}|C{3em}|}
\hline
A & B \\
\hline
u & v \\
x & y \\
\hline
\end{tabular}};
\path[every edge/.style={-stealth,draw}] (A) edge (D.170)
(B) edge (D) (C) edge (D.-170) (D) edge (E);
\end{tikzpicture}
\caption{Embed tabulars in a \texttt{tikzpicture}.}
\end{figure}

\begin{figure}
\centering
\begin{tabular}{cp{1cm}cp{1cm}c}
\tikzmarknode{A}{\begin{tabular}{|C{3em}|C{3em}|}
\hline
A & B \\
\hline
u & v \\
x & y \\
\hline
\end{tabular}} & & & & \\[1cm]
\tikzmarknode{B}{\begin{tabular}{|C{3em}|C{3em}|}
\hline
A & B \\
\hline
u & v \\
x & y \\
\hline
\end{tabular}} & &
\tikzmarknode{D}{\begin{tabular}{|C{3em}|C{3em}|}
\hline
A & B \\
\hline
u & v \\
x & y \\
\hline
\end{tabular}} &&
\tikzmarknode{E}{\begin{tabular}{|C{3em}|C{3em}|}
\hline
A & B \\
\hline
u & v \\
x & y \\
\hline
\end{tabular}} \\[1cm]
\tikzmarknode{C}{\begin{tabular}{|C{3em}|C{3em}|}
\hline
A & B \\
\hline
u & v \\
x & y \\
\hline
\end{tabular}} & & & & \\
\end{tabular}
\begin{tikzpicture}[overlay,remember picture]
\path[every edge/.style={-stealth,draw}] (A) edge (D.170)
(B) edge (D) (C) edge (D.-170) (D) edge (E);
\end{tikzpicture}
\caption{Use \texttt{tikzmark}.}
\end{figure}

\end{document}


This code is about connecting the tables, not making them pretty. If you want to have prettier tables, ask a new question, I'm sure you will get flooded with suggestions using bookmarks and whatever.

• Thank you very much! – user11550 Feb 12 '20 at 18:42