good evening, some suggestion on how to use the following shapes?
1 Answer
I don't think that there exists a library for this kind of diagram and I think, considering the variety and uniqueness of the position of the single elements in the above diagram, it is most probably easiest to just use predefined shapes such as rectangle
and diamond
(the latter being available via the library shapes.geometric
) and add the other things manually.
However, you could of course create your own shapes or enhance existing ones using styles, or you could make use of \pic
s as in the following example which might help you drawing the above diagram (but you should probably make yourself familiar with how \pic
s work in general):
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows.meta}
\tikzset{
% enhanced rectangle
enhanced rectangle/base/.style={
draw,
rectangle,
align=center,
minimum width=7em,
minimum height=2.5em,
inner sep=5pt,
},
enhanced rectangle/text/.initial={},
pics/enhanced rectangle/.style={
code={
\tikzset{#1}
\node[enhanced rectangle/base] (-base) at (0,0) {
\pgfkeysvalueof{/tikz/enhanced rectangle/text}
};
\tikzset{enhanced node additions/construction}
}
},
% enhanced diamond
enhanced diamond/base/.style={
draw,
diamond,
align=center,
minimum width=7.5em,
minimum height=2em,
inner sep=1pt,
},
enhanced diamond/text/.initial={},
pics/enhanced diamond/.style={
code={
\tikzset{#1}
\node[enhanced diamond/base] (-base) at (0,0) {
\pgfkeysvalueof{/tikz/enhanced diamond/text}
};
\tikzset{enhanced node additions/construction}
}
},
% enhanced node additions
enhanced node additions/.initial={},
enhanced node additions/node/.style={draw, circle, inner sep=2pt},
enhanced node additions/label/.style={},
enhanced node additions/radius/.initial={2.25cm and 1.25cm},
enhanced node additions/connected/.code={
\tikzset{
enhanced node additions/connected/path/.style={draw},
enhanced node additions/connected/node/.style={enhanced node additions/node, fill},
}
},
enhanced node additions/connected/path/.style={},
enhanced node additions/connected/node/.style={},
enhanced node additions/connected/start angle/.initial={0},
enhanced node additions/connected/end angle/.initial={0},
enhanced node additions/connected/radius/.initial={1.75cm and 0.75cm},
enhanced node additions/construction/.code={
\pgfkeysgetvalue{/tikz/enhanced node additions}{\enhanceddiamondadditionslist}
\ifx\enhanceddiamondadditionslist\empty\else
\foreach \a/\s/\l [count=\i] in \enhanceddiamondadditionslist {
\tikzset{
enhanced node additions/node \i/.style={},
enhanced node additions/label \i/.style={},
}
\node[enhanced node additions/node, enhanced node additions/node \i, label={[enhanced node additions/label, enhanced node additions/label \i]\a:\l}, \s] (-addition node \i) at (\a:\pgfkeysvalueof{/tikz/enhanced node additions/radius}) {};
\draw (-base) -- (-addition node \i) coordinate[midway] (-addition edge \i);
}
\draw (\pgfkeysvalueof{/tikz/enhanced node additions/connected/start angle}:\pgfkeysvalueof{/tikz/enhanced node additions/connected/radius})
arc (\pgfkeysvalueof{/tikz/enhanced node additions/connected/start angle}:\pgfkeysvalueof{/tikz/enhanced node additions/connected/end angle}:\pgfkeysvalueof{/tikz/enhanced node additions/connected/radius})
node[enhanced node additions/connected/node] (-addition connect node) {};
\fi
},
}
\begin{document}
\begin{tikzpicture}
\pic (rectangle 1) at (0,0) {enhanced rectangle={
enhanced rectangle/text={Edizione corso},
enhanced node additions={
215//Num. part.,
280//Data inizio,
325//Data fine
},
enhanced node additions/connected,
enhanced node additions/connected/start angle=250,
enhanced node additions/connected/end angle=290,
}};
\draw (rectangle 1-base.250) -- ++(0,-2);
\pic (diamond 1) at (5,0) {enhanced diamond={
enhanced diamond/text={Foo},
enhanced node additions={
135/fill/Ciao,
45/fill/Hello,
0//Bye
},
enhanced node additions/connected,
enhanced node additions/connected/start angle=-20,
enhanced node additions/connected/end angle=65,
}};
\node[above] at (diamond 1-addition edge 1) {(1,0)};
\draw (rectangle 1-base) -- (diamond 1-base) node[above, pos=0.25] {(1,N)};
\draw[<-, double, double distance=2pt, >={Triangle[length=5pt]}] (diamond 1-base) -- ++(0,-2);
\end{tikzpicture}
\end{document}
append after command
or the like. But it is crucial to know how these shapes are actually used.rectangle
anddiamond
(via\usetikzlibrary{shapes.geometric}
) shapes and add the other things manually, since they seem to be quite individual for each node. I don't think that there exists a package already for this style of diagrams.