I have several tables that are related to each other. Based on this question, I tried putting the table within a node within a matrix, but this constrains my tables to be arranged in an array. Since my tables do not naturally fit into an array, I need an alternative solution, but I have not been able to find one. Here's what I have so far:
\documentclass{article}
\usepackage{booktabs}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\matrix[ampersand replacement=\&] {
\node (somenode) [shape=rectangle,fill=blue!20] at (0.0,0.0) {
\begin{tabular}{lc} \toprule
Name & Color \\ \midrule
A.N. Other & Blue \\
J. Bloggs & Grey \\
\bottomrule
\end{tabular}
}; \&
\node (somenode) [shape=rectangle,fill=orange!20] at (1.0,-2.0) {
\begin{tabular}{lc} \toprule
Name & Color \\ \midrule
A.N. Other & Blue \\
J. Bloggs & Grey \\
\bottomrule
\end{tabular}
};
\\
};
\end{tikzpicture}
\end{document}
which produces:
What I need to do is:
- Position the tables arbitrarily,
- Draw arrows between the tables to indicate their relations,
- Have text directly above the table (as a sort of caption),
which would end up looking something like this (I've repeated the first table for simplicity but tables 3 and 4 would naturally be different):
Any pointers would be appreciated.
Best Answer
If you want to put the nodes at arbitrary places, why use a matrix? For example:
gives:
If you want the label without a background it is just a matter of putting two nodes one at the top of the other (using anchors is quite easy), and to avoid the arrows touching the boxes you can use either
shorten >
or anouter sep
in the nodes.For example, in the next code, I define a macro to position the tabular and its caption, and then I encompass them with a node which is the addressable one.