Quantcast
Channel: Question and Answer » tikz-arrows
Viewing all articles
Browse latest Browse all 33

Flowchart using TiKz – connecting arrows

$
0
0

Here is flowchart drawn using TiKz. I’m trying to connect the arrows in a clean way. For instance, I want to connect box3.west to retF.south and box2.east to retT.south. I would like to have the arrow end at the midpoint of retF.south and retT.south. Is there a general way to do this?

enter image description here

documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes.geometric,arrows,fit,matrix,positioning,shapes.multipart}
tikzset
{
        process/.style={rectangle, minimum width=2cm, minimum height=1cm, align=center, text width=2cm, draw},
        arrow/.style={thick, ->, >=stealth},
        decision/.style ={diamond, draw=black, minimum width=1cm, minimum height=1cm, text badly centered, node distance=3cm, inner sep=0pt}
}
begin{document}
begin{figure}[htp]
centering
{
    begin{tikzpicture}[scale=0.5, transform shape]
    node (p0) [] {foo(K)};
    node (p1) [process, below of=p0, text width=4cm] {box1};
    node (p2) [process, below of=p1, yshift=-1.5cm, text width=4.5cm] {box2};
    node (p3) [decision, below of=p2, yshift=-1.5cm, text width=2cm] {box3};
    node (retT) [process, right of=p1, xshift=4cm, text width=1cm, minimum width=1cm] {retT};
    node (retF) [process, left of=p2, xshift=-5cm, text width=1cm, minimum width=1cm] {retF};


    draw [arrow] (p1) -- node[anchor=west] {need more steps} (p2);
    draw [arrow] (p1) -- node[anchor=south] {no more steps} (retT);
    draw [arrow] (p2.east) -- ++(1.5,0) node[anchor=north,pos=1] {K = X}   |- (retT.west);
    draw [arrow] (p2.west) -- node[anchor=north,pos=0.5] {K $<$ X}  (retF.east);
    draw [arrow] (p2) -- node[anchor=east] {K $>$ X} (p3);
    draw [arrow] (p3.west) --+(-4.2,0)  node[anchor=north]{No} |- (retF.south);

    end{tikzpicture}
}
caption{connect box3.west to retF.south}
end{figure}
end{document}

Viewing all articles
Browse latest Browse all 33

Trending Articles