Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
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 '12 at 22:08
add comment

1 Answer

up vote 20 down vote accepted

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

share|improve this answer
    
Perfect. This is exactly what I was looking for. Thanks! –  Matt Jan 7 '12 at 22:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.