For the first problem, nodes having the same size, see Dependent node size in TikZ (which solution I am going to use) and the linked questions which comes down to identifying the widest/tallest/deepest element and giving its measurements as options to the nodes (see text width
, text height
and text depth
). I am using my node-families
library from the linked question/answer.
The second problem, better connections between the matrices, see for example the very last example of my answer to Converging and diverging nodes in a flowchart and many others that use (angle) anchors and |-
/-|
as coordinate specifications. I am going to use a specific mix which includes the use of my paths.ortho
library.
Your fourth point, regarding the use of matrices, I think that this is a good example to use matrices, even though we only have one column per matrix. For more complicated stuff and maybe even the matrices with the bold black border, one can use a combination of the fit
and the backgrounds
library. For examples see my answers [1] and [2].
Now, the black borders will require work. I am using here a solution that first places the fully filled node (Mikro- and Makroebene), and then adds a matrix directly below it which both are then fit
ted with a node that is only used for the draw
n line around it.
There are many different approaches possible for this problem. It is our advantage that these problematic matrices are only placed in the lower row of all matrices and only to the right of other matrices. Note the xshift
and yshift
in the Title
style. If you want to place it to the left, you need to use a negative yshift
value (well, at least if you want to use the “correct” node distance). If you want to place such matrices above other nodes/matrices, you better first place the matrix part of this structure (then with a positive yshift
for correction of the black border) and then the Title
above it (but then without any shifting values).
My positioning-plus
library adds another set of …=of …
keys to the positioning
library (and also loads fit
). This introduces the north right=of <ref-node>
key that basically is the same as right=of <ref-node>.north east, anchor=north west
.
This library also allows us to use x_node_dist
and y_node_dist
as a reference to the node distances that is set with the node distance
key.
Code
\documentclass[tikz,border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix, positioning-plus, node-families, paths.ortho}
\tikzset{
matrix inner xsep/.style={
/tikz/every node/.append style/.expanded={inner xsep={\pgfkeysvalueof{/pgf/inner xsep}}},
/pgf/inner xsep={#1}},
matrix inner ysep/.style={
/tikz/every node/.append style/.expanded={inner ysep={\pgfkeysvalueof{/pgf/inner ysep}}},
/pgf/inner ysep={#1}},
matrix inner sep/.style={matrix inner xsep={#1}, matrix inner ysep={#1}},
}
\begin{document}
\begin{tikzpicture}[
my matrix*/.style={
matrix inner sep=+1em,
matrix of nodes,
nodes={typetag, Minimum Width=m, text depth=+0pt},
row sep=+.5em,
Minimum Width=M},
my matrix/.style={
my matrix*, draw,
row 1/.append style={nodes=title}},
title/.style={draw=none, font=\bfseries},
Title/.style={
title,
outer sep=+0pt,
Minimum Width=M,
fill, text=white,
text depth=+0pt,
yshift=+-.25cm,
xshift=+.25cm,
inner ysep=.5em},
fitty/.style={fit=(#1')(#1''), line width=+.25cm, inner sep=+.125cm, draw, name=#1},
typetag/.style={draw=black, inner sep=1ex, align=center},
]
\matrix[my matrix] (mx1) {
Text A \\
Text 1 \\
Text 2 \\
Text 3 \\
Text 4 \\
Text 5 \\
Text 6 \\
};
\node[Title, north right=of mx1] (mx2') {Text D};
\matrix[my matrix, below=+0pt of mx2'] (mx2'') {
\node {Text ABC};\\
Text 13 \\
Text 14 \\
Text 15 \\
Text 16 \\
Text 17 \\
\node{Text 18}; \\
};
\node[fitty=mx2]{};
\node[Title, north right=of mx2] (mx3') {Text E};
\matrix[my matrix*, below=+0pt of mx3'] (mx3'') {Text 19 \\};
\node[fitty=mx3] {};
\matrix[my matrix, above=of mx2.north, matrix anchor=south east, shift=(left:.5*x_node_dist)] (mx5) {
Text B \\
\node{Text 7}; \\
Text 8 \\
Text 9 \\
\node{Text 10}; \\
Text 11 \\
};
\matrix[my matrix, north right=of mx5] (mx4) {
Text C \\
\node {Text 12}; \\
};
\path [thick, ->, >=latex]
{
[to path={([shift=(down:y_node_dist)]\tikztostart.north east) -- ([shift=(down:y_node_dist)]\tikztotarget.north west)}]
(mx1) edge (mx2)
(mx2) edge[<-] (mx3)
}
[|*] ([shift=(left:x_node_dist)] mx5.south east) edge (mx2)
([shift=(right:x_node_dist)] mx4.south west) edge (mx2)
;
\end{tikzpicture}
\end{document}
Output
I've never used TikZEdt, but the first thing that strikes me is that you can place the tabular
s in node
s. That is, start with
\begin{tikzpicture}
\node (tab1) {%
\begin{tabular}{ccc}
ID & Ord & Event\\
\hline
Ana & 1 & A\\
Tom & 1 & A\\
Tom & 2 & B\\
Tom & 3 & D\\
\end{tabular}};
\end{tikzpicture}
and go from there.
For more tables, I suggest adding \usetikzlibrary{positioning}
to the preamble (Code prepended in Settings -> compiler options), and then using something like
\begin{tikzpicture}
\node (tab1) {%
\begin{tabular}{ccc}
ID & Ord & Event\\
\hline
Ana & 1 & A\\
Tom & 1 & A\\
Tom & 2 & B\\
Tom & 3 & D\\
\end{tabular}
};
\node [right=of tab1,yshift=2cm] (tab2) {%
\begin{tabular}{ccc}
ID & Ord & Event\\
\hline
Ana & 1 & A\\
Tom & 1 & A\\
\end{tabular}
};
\end{tikzpicture}
Best Answer
Here's a quick demonstration with TikZ, partly based on Thruston's Metapost answer.
Starting with the squares, the simples way of making those is TikZ'
rectangle
operation, which is used asSo simply specify the coordinates of two opposite corners, with the word
rectangle
between.For the other shapes, you can draw the lines segment by segment, e.g.
which draws a line from (0,0) to (0,1) to (1,1).
To add the dots at the end of the line, you can use an arrow tip from the
arrows.meta
library. Hence, you need to add\usetikzlibrary{arrows.meta}
to the preamble. Arrow tips are specified in the optional argument to a\draw
command, generally as\draw [<name of arrow tip>-<name of arrow tip>] ...;
. Arrow tips can be added to one or both ends of a path.So to add a black dot at the ends of the line, use
Circle[]
is the name of the arrow tip. The reason for the brace pair ({}
) around it is that you need to "hide" the brackets from the parser, so that the closing bracket (]
) of the arrow tip isn't confused with the closing bracket for the optional argument(s) to\draw
.The arc can be drawn in several ways. In the code below I've used the syntax
(x1,y1) .. controls (x2,y2) and (x3,y3) .. (x4,y4)
. This draws a curved line between(x1,y1)
and(x4,y4)
. I can't explain how this works better than the first tutorial in TikZ' manual, so I'm quoting that, section 2.4:The control points I've used are one unit to the right of the start and end point.
There are two other bits of syntax used in the code below that I added because they could be useful. The first is the
scope
environment, which allows you to add settings to all commands within. Here I've usedUnsurprisingly, what this will do is to move the coordinates of the paths within it 3cm to the right. (Could at this point mention that the default unit length is 1cm, so
\draw (0,0) -- (0,1);
will draw a line that is 1cm long.)The other bit is the use of relative coordinates. For example, if you write
\draw (1,1) -- +(1,0) -- +(1,1);
this will draw a line from(1,1)
to(1+1,1+0) = (2,1)
to(1+1,1+1) = (2,2)
. With\draw (1,1) -- ++(1,0) -- ++(1,1);
(note two plus signs) this will draw a line from(1,1)
to(1+1,1+0) = (2,1)
to(2+1,1+1) = (3,2)
. In other words, with one plus sign, the previous explicit coordinate will always be the reference point, but with two plus signs, the reference coordinate will be moved.That said, going through the tutorials in the TikZ manual (chapters 2-6), as mentioned in the comments by Tom Bombadil, would probably have learned you all of this and a lot more.