\documentclass{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[cross/.style={path picture={
\draw[black]
(path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);
}}]
\node [draw](A){start};
\node [draw,circle,cross,minimum width=1 cm](B) at (3,0){};
\node [draw](C) at( 5,0){end};
\draw[->] (A) -- (B) -- (C);
\end{tikzpicture}
\end{document}
This answer makes use of the following TikZ libraries:
shapes.geometric
for the diamond
shapes
positioning
for the relative positioning of nodes ( …=… of …
)
fit
for fitting nodes around other ones (fit=(…)(…) …
)
calc
for the positioning of the diamond nodes
The node f
is on the same height as b
and d
. The node e
is on the same height as the left diamond (dia1
).
The right big rectangles enclosing e
and f
uses the coordinate dia1.north -| e
to fit, so that it has the same height as the other big rectangle.
Should the “plussed” diamond on the bottom be horiztonally centered between the big rectangles use
\node[dia cross] at ([yshift=-.5cm]$(left.south east)!.5!(right.south west)$) (dia2) {};
for the placement (notice the anchors south east
and south west
).
Code
\documentclass[tikz]{standalone}
\usetikzlibrary{
shapes.geometric,
positioning,
fit,
calc
}
\tikzset{
dia/.style={
shape=diamond,
minimum size=2em,
},
dia cross/.style={
dia,
% path picture={
% \draw (path picture bounding box.west) -- (path picture bounding box.east)
% (path picture bounding box.north) -- (path picture bounding box.south);
% },
append after command={
\pgfextra
\draw[shorten >=\pgflinewidth,shorten <=\pgflinewidth]
(\tikzlastnode.west) -- (\tikzlastnode.east);
\draw[shorten >=\pgflinewidth,shorten <=\pgflinewidth]
(\tikzlastnode.north) -- (\tikzlastnode.south);
\endpgfextra
}
}
}
\begin{document}
\begin{tikzpicture}[
every node/.append style={draw,minimum width=3em,minimum height=1.5em},
>=latex
]
%%% Left side
%% nodes with text
\node (a) {a};
\node[below=.5 of a] (b) {b};
\node[right=of a] (c) {c};
\node[below=.5 of c] (d) {d};
%% rectangles around nodes with text
\node[fit=(a)(b)] (ab) {};
\node[fit=(c)(d)] (cd) {};
%% top diamond
\node[dia] at ([yshift=.5cm]$(ab.north)!.5!(cd.north)$) (dia1) {};
%%% Right side
\node[right=2 of d] (f) {f};
\node[label={[inner sep=0pt,minimum height=2ex]above:h?}] at (f |- dia1) (e) {e};
% fake f to get the same spacing as on the left side (text with draw=gray)
\node[fit=(f),draw=none] (f') {};
%%% Big rectangles
\node[inner sep=1em,fit=(ab)(cd)(dia1)] (left) {};
\node[inner sep=1em,fit=(f')(dia1.north -| e)] (right) {};
%%% Diamond below
\node[dia cross] at ([yshift=-.5cm]$(left.south)!.5!(right.south)$) (dia2) {};
%%% Arrows
\foreach \pp/\pf/\pt in {--/a/b,
--/c/d,
--/e/f,
-|/dia1/ab,
-|/dia1/cd,
|-/left/dia2,
|-/right/dia2}
\draw[
shorten >=\pgflinewidth,
->
] (\pf) \pp (\pt);
\end{tikzpicture}
\end{document}
Output
Best Answer
You can use
[shift=<length>]
option (shown in red), or withtikz
'scalc
library you can perform coordinate calculations (shown in blue). Also, if you desire rounded corners as per your original image you can add therounded corners=<length>
as I have done for the red version:Code: