I tried to adopt the solutions (from previous question) to five different yet quite similar diagrams which worked pretty well. However, I still have some questions. 
How do I have to change the code so the lines are in one line?
Same as in one.
I need to write some text there. I tried it with the \node command which didn't work well. Which command do I need to use?
4.&5. I should make some annotations within the diagram. I tried to make the speech bubbles with node shapes but without success.
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary{
positioning,
shapes.geometric,
chains,
calc,
fit,
arrows.meta,
backgrounds,
quotes,
matrix
}
\begin{document}
\begin{tikzpicture}[
font=\footnotesize\sffamily,
baserect/.style={
text width=3cm,
align=center,
draw
},
diam/.style={
diamond,
draw,
align=center,
text width=1.5cm,
inner sep=1pt,
fill=black,
text=white
},
basecirc/.style={
circle,
draw,
align=center,
text width=1.5cm
},
persohnlich/.style={
basecirc,
fill=black!60,
text=white
},
finanziell/.style={
basecirc,
fill=black!30
},
keine/.style={
basecirc,
fill=white
},
]
\begin{scope}[
start chain=groups,
node distance=-\pgflinewidth,
every node/.append style={
baserect,
on chain,
font=\footnotesize\sffamily\bfseries,
minimum height=2cm,
fill=black!20,
}
]
\node {Schweizer Männer};
\node {Schweizer Frauen};
\node {Ausländer \\(niedergelassene Männer mit ausländischer Staatsangehörigkeit)};
\node {Ausländerinnen (niedergelassene Frauen mit ausländischer Staatsangehörigkeit)};
\end{scope}
\begin{scope}[
start chain=values,
node distance=-\pgflinewidth,
every node/.append style={
baserect,
on chain,
minimum height=1cm
}
]
\node [anchor=north] at (groups-1.south) {dienstpflichtig};
\node {freiwillig};
\node {freiwillig, nur Katastrophen-\\schutz};
\node {freiwillig, nur Katastrophen-\\schutz};
\end{scope}
\node [diam, below=2cm of values-1] (tauglich) {sicherheits-\\dienst\\-tauglich?};
\node [diam, right=4.2 of tauglich, inner sep=-2pt] (IV) {IV bzw.\\Integritäts-\\schädigung\\>40\%?};
\node [keine, right=0.75cm of IV] (EG) {keine\\Ersatz-\\abgabe};
\node [diam, below=of tauglich] (Gewissen) {mit\\Gewissen\\vereinbar?};
\node [finanziell, at=(IV|-Gewissen)] (Ersatzabgabe) {Ersatz\-abgabe};
\node [persohnlich, below=of Gewissen] (Armee) {Armee};
\node [finanziell, right=0.3 of Armee, , left color=black!60, right color=black!30,shading angle=90] (Schutz) {Katastrophen-\\schutz};
\draw [-Triangle, line width=2mm] (values-1) -- coordinate (mid) (tauglich);
\draw [dashed, ultra thick] (values-2) |- (mid);
\draw [dashed, thick] (values-3) -- (values-3 |- mid) ;
\draw [dashed, thick] (values-4) |- (values-2 |- mid);
\coordinate (a) at (2.2,-11);
\coordinate (b) at (0,-7.2);
\draw [thick] [-] (a) |- (b);
\coordinate (a) at (2.2,-11);
\coordinate (c) at (1,-8.85);
\draw [thick] [-] (a) |- (c);
\path[near start,thick]
(tauglich) edge["JA"] (Gewissen)
(Gewissen) edge["JA"] (Armee)
(tauglich) edge["NEIN"] (IV)
(IV) edge["JA"] (EG)
(IV) edge["NEIN"] (Ersatzabgabe);
\node [draw,fit=(Armee)(EG), inner sep=5mm] (frame) {};
\matrix [
above left,
matrix of nodes,
nodes={anchor=west}
] (m) at (frame.south east) {
&&[0.5cm] |[persohnlich,text width=0cm]| & persöhnliche Dienstleistung \\
&& |[finanziell,text width=0cm]| &finanzielle Ersatzgabe \\
|[draw,minimum size=8pt]| & Sicherheitsdienstpflicht & |[keine,text width=0cm]| & keine Leistung \\
};
\end{tikzpicture}
\end{document}
As you can see the nodes cover the text. How can I enlarge the frame so it fits?
\documentclass[border=5mm]{standalone} \usepackage{tikz} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usetikzlibrary{ positioning, shapes.geometric, % for diamond shape chains, % for automatic placement nodes relative to the previous one, in "chains" calc, % for ($...$) syntax of coordinate calculation fit, % to create a node that fits around other specified nodes arrows.meta, % for Triangle arrow tip backgrounds, % for "on background layer", to place something behind already existing stuff quotes, % for edge["label"] syntax, easy way of placing text along an edge matrix % for matrix of nodes } \begin{document} \begin{tikzpicture}[ font=\footnotesize\sffamily, baserect/.style={ % base style for rectangles on top of the diagram text width=3cm, align=center, draw }, diam/.style={ % style for the black diamonds diamond, draw, align=center, text width=1.5cm, inner sep=1pt, fill=black, text=white }, basecirc/.style={ % basic circle style, used in the next three styles circle, draw, align=center, text width=1.5cm }, persohnlich/.style={ basecirc, fill=black!60, text=white }, finanziell/.style={ basecirc, fill=black!30 }, keine/.style={ basecirc, fill=white }, ] \begin{scope}[ % in this scope, start a chain called groups. nodes in this chain are named groups-1, groups-2 etc. start chain=groups, % set distance between nodes in the chain node distance=-\pgflinewidth, every node/.append style={ % set style for all the nodes in the scope baserect, on chain, % adds all the nodes to the chain font=\footnotesize\sffamily\bfseries, minimum height=2cm, fill=black!20, } ] % now add all the nodes, no additional styling or positioning needed \node {Schweizer Männer}; \node {Schweizer Frauen}; \node {Ausländer \\(niedergelassene Männer mit ausländischer Staatsangehörigkeit)}; \node {Ausländerinnen (niedergelassene Frauen mit ausländischer Staatsangehörigkeit)}; \end{scope} % this scope is basically the same as the previous one. % one main difference is that the first node in the chain is % placed on the lower edge of the first node in the previous chain \begin{scope}[ start chain=values, node distance=-\pgflinewidth, every node/.append style={ baserect, on chain, minimum height=1cm } ] \node [anchor=north] at (groups-1.south) {dienstpflichtig}; \node {freiwillig}; \node {dienstpflichtig, (kein Zugang zur Armee)}; \node {dienstpflichtig, (kein Zugang zur Armee)}; \end{scope} % the nodes in the first row of the flow chart \node [diam, below=2cm of values-1] (tauglich) {dienst-\\tauglich?}; \node [keine, right=7.9 of tauglich] (EG) {keine\\Ersatz-\\abgabe}; % last node in flow chart \node [persohnlich, below=of tauglich] (Armee) {Armee}; \node [persohnlich, right=0.75cm of Armee] (Feuerwehr) {Feuerwehr}; \node [persohnlich, right=0.75cm of Feuerwehr] (Zivilschutz) {Zivilschutz}; \node [persohnlich, right=0.75cm of Zivilschutz] (SRK) {Einsatz-\\organisationen\\SRK*}; \node [persohnlich, right=0.75cm of SRK] (Gemeinschaftsdienste) {Gemeinschaftsdienste}; % draw thick arrow from the dienstpflichtig node to the first node in the flow chart % add a coordinate named "mid" halfway along the arrow, that is used to draw the dashed lines \draw [-Triangle, line width=2mm] (values-1) -- coordinate (mid) (tauglich); % here (values-2) |- (mid) means draw a vertical, then horizontal, % line from values-2 to mid \draw [line width=2mm] (values-2) |- (mid); \draw [line width=2mm] (values-3) |- (mid); \draw [line width=2mm] (values-4) |- (mid); % here the -|/|- syntax is used both for coordinate specifications and path specifications %\draw [dashed, thick] (values-3) -- (values-3 |- mid) -| (schutzdienst); %\draw [dashed, thick] (values-4) |- (values-3 |- mid); % draw the coloured background for the top right part of the flow chart, using a fit node %\begin{scope}[on background layer] % \node [fill=black!10, fit=(Zivilschutz)(EG), inner sep=3mm] {}; %\end{scope} % draw the connections in the flow chart % the ".." syntax comes from the quotes library \path[near start,thick] (tauglich) edge["JA"] (Armee) (tauglich) edge["NEIN"] (EG); \coordinate (a) at (2.5,-7.28); \coordinate (b) at (0,-6.8); \draw [-] (a) |- (b); \coordinate (c) at (5,-7.28); \coordinate (b) at (0,-6.8); \draw [-] (c) |- (b); \coordinate (d) at (7.7,-7.16); \coordinate (b) at (0,-6.8); \draw [-] (d) |- (b); \coordinate (e) at (10.5,-7.29); \coordinate (b) at (0,-6.8); \draw [-] (e) |- (b); % use fit again, to draw the surrounding frame \node [draw,fit=(Armee)(EG), inner sep=5mm] (frame) {}; % use a matrix to make the legend \matrix [ above left, matrix of nodes, nodes={anchor=west} ] (m) at (frame.south east) { &&[1cm]|[keine,text width=0cm]| & keine Leistung \\ |[draw,minimum size=8pt]| & Allgemeine Diensptpflicht & |[finanziell,text width=0cm]| &finanzielle Ersatzgabe \\ }; \end{tikzpicture} \end{document}
Thank you for your help!
EDIT: I tried to use marmot's solution regarding the second question. I worked fine with the other diagrams. However, with one it didn't work. What do I have to correct in the code so it works?
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary{
positioning,
shapes.geometric, % for diamond shape
chains, % for automatic placement nodes relative to the previous one, in "chains"
calc, % for ($...$) syntax of coordinate calculation
fit, % to create a node that fits around other specified nodes
arrows.meta, % for Triangle arrow tip
backgrounds, % for "on background layer", to place something behind already existing stuff
quotes, % for edge["label"] syntax, easy way of placing text along an edge
matrix % for matrix of nodes
}
\begin{document}
\begin{tikzpicture}[
font=\footnotesize\sffamily,
baserect/.style={ % base style for rectangles on top of the diagram
text width=3.55cm,
align=center,
draw
},
diam/.style={ % style for the black diamonds
diamond,
draw,
align=center,
text width=1.5cm,
inner sep=1pt,
fill=black,
text=white,
minimum size=2.5cm
},
basecirc/.style={ % basic circle style, used in the next three styles
circle,
draw,
align=center,
text width=1.5cm,
},
persohnlich/.style={
basecirc,
fill=black!60,
text=white,
text width=1.7cm,
minimum size=2.2cm
},
finanziell/.style={
basecirc,
fill=black!30,
minimum size=2.2cm
% text=white
},
keine/.style={
basecirc,
fill=white,
minimum size=2.2cm
},
matrix1/.style={
basecirc,
fill=black!60,
text=white
},
matrix2/.style={
basecirc,
fill=black!30,
% text=white
},
matrix3/.style={
basecirc,
fill=white
},
]
\begin{scope}[
% in this scope, start a chain called groups. nodes in this chain are named groups-1, groups-2 etc.
start chain=groups,
% set distance between nodes in the chain
node distance=-\pgflinewidth,
every node/.append style={ % set style for all the nodes in the scope
baserect,
on chain, % adds all the nodes to the chain
font=\footnotesize\sffamily\bfseries,
minimum height=2cm,
fill=black!20,
}
]
% now add all the nodes, no additional styling or positioning needed
\node {Schweizer Männer};
\node {Schweizer Frauen};
\node {Ausländer \\(niedergelassene Männer mit ausländischer Staatsangehörigkeit)};
\node {Ausländerinnen (niedergelassene Frauen mit ausländischer Staatsangehörigkeit)};
\end{scope}
% this scope is basically the same as the previous one.
% one main difference is that the first node in the chain is
% placed on the lower edge of the first node in the previous chain
\begin{scope}[
start chain=values,
node distance=-\pgflinewidth,
every node/.append style={
baserect,
on chain,
minimum height=1cm
}
]
\node [anchor=north] at (groups-1.south) {dienstpflichtig};
\node {freiwillig};
\node {dienstpflichtig, (kein Zugang zur Armee)};
\node {dienstpflichtig, (kein Zugang zur Armee)};
\end{scope}
% the nodes in the first row of the flow chart
\node [diam, below=2cm of values-1] (tauglich) {dienst-\\tauglich?};
\node [keine, right=7.9 of tauglich] (EG) {keine\\Ersatz-\\abgabe};
% last node in flow chart
\node [persohnlich, below=3cm of tauglich] (Armee) {Armee};
\node [persohnlich, right=0.75cm of Armee] (Feuerwehr) {Feuerwehr};
\node [persohnlich, right=0.75cm of Feuerwehr] (Zivilschutz) {Zivilschutz};
\node [persohnlich, right=0.75cm of Zivilschutz] (SRK) {Einsatz-\\organisationen\\SRK*};
\node [persohnlich, right=0.75cm of SRK] (Gemeinschaftsdienste)
{Gemein-\\schafts-\\dienste};
% draw thick arrow from the dienstpflichtig node to the first node in the flow chart
% add a coordinate named "mid" halfway along the arrow, that is used to draw the dashed lines
\draw [-Triangle, line width=2mm] (values-1) -- coordinate (mid) (tauglich);
% here (values-2) |- (mid) means draw a vertical, then horizontal,
% line from values-2 to mid
\draw [line width=2mm] (values-2) |- (mid);
\draw [line width=2mm] (values-3) |- (mid);
\draw [line width=2mm] (values-4) |- (mid);
% here the -|/|- syntax is used both for coordinate specifications and path specifications
%\draw [dashed, thick] (values-3) -- (values-3 |- mid) -| (schutzdienst);
%\draw [dashed, thick] (values-4) |- (values-3 |- mid);
% draw the coloured background for the top right part of the flow chart, using a fit node
%\begin{scope}[on background layer]
% \node [fill=black!10, fit=(Zivilschutz)(EG), inner sep=3mm] {};
%\end{scope}
% draw the connections in the flow chart
% the ".." syntax comes from the quotes library
\path[near start,thick]
(tauglich) edge["JA",swap] (Armee)
(tauglich) edge["NEIN"] (EG);
\node[text width=4cm] at (2.5,-7.8) {Freie Wahl nach Massgabe der Tauglichkeit, der Eignung; Personalbedrüfnisse der Armee müsssen gesichert sein};
\node[text width=4cm] at (1,-12) {{\tiny *Organisationen des Schweiz. Roten Kreuzes, die in das Dispositiv eines Kantons zur Bewältigung von Katastrophen und Notlagen integriert sind}};
\coordinate (b) at (0,-8.8);
\draw [-] (Armee.north) |- (b);
\draw [-] (Feuerwehr.north) |- (b);
\draw [-] (Zivilschutz.north) |- (b);
\draw [-] (SRK.north) |- (b);
\draw [-] (Gemeinschaftsdienste) |- (b);
% use a matrix to make the legend
\matrix [
below=1.1cm of Gemeinschaftsdienste.east,
anchor=north east,
matrix of nodes,
nodes={anchor=west}
] (m) {
&&[1cm]|[matrix3,text width=0cm]| & keine Leistung \\
|[draw,minimum size=8pt]| & Allgemeine Diensptpflicht & |[matrix2,text width=0cm]| &finanzielle Ersatzgabe \\
};
% use fit again, to draw the surrounding frame
\node[fit=(groups-1) (groups-4) (values-1) (values-4),draw,inner
sep=-\pgflinewidth/2](upper fit){};
\foreach \X[count=\Y] in {2,3,4}
{\draw ($(groups-\Y.south east)!0.5!(groups-\X.south west)$) coordinate(aux)
-- (aux|-upper fit.south);}
\coordinate (aux-L) at ([xshift=5mm+\pgflinewidth]upper fit.west|-Armee.center);
\coordinate (aux-R) at ([xshift=-5mm-\pgflinewidth]upper fit.east|-Armee.center);
\node [draw,fit=(Armee)(EG)(aux-L)(aux-R), inner sep=5mm] (frame) {};
\end{tikzpicture}
\end{document}





\node [draw,fit=(Armee)(EG)(aux-L)(aux-R) (m), inner sep=5mm] (frame) {};. – Sep 06 '18 at 19:15