18

I've been creating a flow chart using the template I found here:

http://www.texample.net/tikz/examples/simple-flow-chart/

Please see the code below:

\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
% Define block styles
\tikzstyle{decision} = [diamond, draw, fill=blue!20, 
    text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, fill=blue!20, 
    text width=5em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,
    minimum height=2em]
\begin{document}
\begin{tikzpicture}[node distance = 2cm, auto]
    % Place nodes
         \node [cloud] (a) {a};
        \node [block, right of = a, node distance =5cm] (b) {b};
        \node [decision, below of = b] (c) {c};
        \node [block, below of = c, node distance = 3cm] (d) {d};
        \node [decision, below of = d, node distance = 3.2cm] (e) {e};
        \node [block, right of = e, node distance = 3.2cm] (f) {f};
        \node [decision, below of = e] (g) {g};
        \node [block, left of = g, node distance = 3.2cm] (h) {h};
        \node [decision, below of = g, node distance = 3.5cm] (i) {i};
        \node [block, left of = i, node distance = 3.2cm] (j) {j};
        \node [block, right of = i, node distance = 3.5cm] (k) {k};
     % Draw edges
    \path [line] (a) -- (b);
    \path [line] (b) -- (b);
    \path [line] (b) -- node [near start] {yes} (d);
    \path [line] (d) -- (e);
    \path [line] (e) -- node [near start] {no} (f);
    \path [line] (f) |- (b);
    \path [line] (e) -- node [near start] {yes} (g);
    \path [line] (g) -- node [near start] {no} (h);
    \path [line] (h) |- (e);
    \path [line] (g) -- node [near start] {yes} (i);
    \path [line] (i) -- node [near start] {yes} (j);
    \path [line] (j) -- (h);
    \path [line] (i) -- node [near start] {no} (k);
    \path [line] (k) -| (h);
\end{tikzpicture}
\end{document}

How can I create an arrow from k to h that doesn't intersect any of the other boxes or arrows?

1
  • 1
    Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). Also, you forgot to load a document class in your code, and \usepackage is used in the preable, i.e. before \begin{document}. I fixed all this for you.
    – doncherry
    Jan 7, 2012 at 22:08

1 Answer 1

26

Here's a way: let's go around the node j. We use the left bottom corner (south west), shift a bit to not touch the node. Further we use |- to get vertical and horizontal path parts.

\path[line] (k) |- ([xshift=-0.5cm,yshift=-0.5cm]j.south west) |- (h);

enter image description here

1
  • Perfect. This is exactly what I was looking for. Thanks!
    – Matt
    Jan 7, 2012 at 22:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .