2

I have this;

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fit,arrows,calc,positioning,shapes.geometric}

\begin{document}
\tikzstyle{b} = [rectangle, draw, fill=blue!20, node distance=1cm, text     width=6em, text centered, rounded corners, minimum height=4em, thick]
\tikzstyle{h} = [rectangle, draw, fill=green!20, node distance=3cm, text width=6em, text centered, rounded corners, minimum height=4em, thick]

\tikzstyle{pregunta} = [diamond, draw, fill=yellow!20, node distance=1cm, text width=6em, text centered, rounded corners, minimum height=1em, thick,inner sep=0pt]

\tikzstyle{salir} = [rectangle, draw, fill=red!20, node distance=1cm, text width=6em, text centered, rounded corners, minimum height=2em, thick, inner sep=0pt]

\tikzstyle{multi} = [rectangle, draw, fill=blue!20, node distance=1cm, text width=15em, rounded corners, minimum height=2em, thick,inner sep=5pt]

\tikzstyle{reiniciar} = [rectangle, draw, fill=brown!20, node distance=1cm, text width=6em, text centered, rounded corners, minimum height=2em, thick, inner sep=0pt]


\tikzstyle{c} = [rectangle, draw, inner sep=0.5cm, dashed]
\tikzstyle{l} = [draw, -latex',thick]
\begin{center}
    \begin{tikzpicture}[auto]
    \node [h] (a) {};
    \node [pregunta, below=of a] (b) {};
    \node [b, below=of b,xshift=-3cm,yshift=1.5cm] (c) {};
    \node [b, below=of c,yshift=-1cm,xshift=3cm] (d) {};
    \node [pregunta, below=of d,yshift=0.5cm] (e) {};
    \node [salir, below=of e] (f) {};


    \node [multi, below=of b,xshift=4cm,yshift=1.5cm] (g) { };

    \node [reiniciar, left=of e,yshift=1.5cm,xshift=-1cm] (h) {};  

    \draw [l] (a) -- (b);
    \draw [l] (b)-|(c)node [anchor=north, yshift=+2.5cm] {};
    \draw [l] (b)-|(g)node [anchor=north, yshift=+3.2cm] {};
    \draw [l] (e)--(f)node [anchor=west, yshift=1cm] {};
    \draw [l] (d)--(e);
    \draw [l] (e)-|(h);
    %\draw [l] (h)|-(b);HERE!


    \draw [dashed,thick] (c) |- (d) node [midway,fill=white] {hello};
    \draw [dashed,thick] (g) |- (d) node [midway,fill=white] {hello};
    \end{tikzpicture}
\end{center}
\end{document}

enter image description here

I want this, arrow to the top off Diamond:

enter image description here

How can I do it?

Thank you

1

I added this to your code:

\node [xshift=-0.5cm] at (h) (y) {};
\node [yshift= 1cm] at (b) (z) {};

\pgfdeclarelayer{background}
\pgfsetlayers{background,main}

\begin{pgfonlayer}{background}
  \draw [l,red,ultra thick] (y) |- (z);
\end{pgfonlayer}

I had to use pgfonlayer to draw the arrow behind the reiniciar node.

The full code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fit,arrows,calc,positioning,shapes.geometric}

\begin{document}
\tikzstyle{b} = [rectangle, draw, fill=blue!20, node distance=1cm, text     width=6em, text centered, rounded corners, minimum height=4em, thick]
\tikzstyle{h} = [rectangle, draw, fill=green!20, node distance=3cm, text width=6em, text centered, rounded corners, minimum height=4em, thick]

\tikzstyle{pregunta} = [diamond, draw, fill=yellow!20, node distance=1cm, text width=6em, text centered, rounded corners, minimum height=1em, thick,inner sep=0pt]

\tikzstyle{salir} = [rectangle, draw, fill=red!20, node distance=1cm, text width=6em, text centered, rounded corners, minimum height=2em, thick, inner sep=0pt]

\tikzstyle{multi} = [rectangle, draw, fill=blue!20, node distance=1cm, text width=15em, rounded corners, minimum height=2em, thick,inner sep=5pt]

\tikzstyle{reiniciar} = [rectangle, draw, fill=brown!20, node distance=1cm, text width=6em, text centered, rounded corners, minimum height=2em, thick, inner sep=0pt]


\tikzstyle{c} = [rectangle, draw, inner sep=0.5cm, dashed]
\tikzstyle{l} = [draw, -latex',thick]
\begin{center}
    \begin{tikzpicture}[auto]
    \node [h] (a) {};
    \node [pregunta, below=of a] (b) {};
    \node [b, below=of b,xshift=-3cm,yshift=1.5cm] (c) {};
    \node [b, below=of c,yshift=-1cm,xshift=3cm] (d) {};
    \node [pregunta, below=of d,yshift=0.5cm] (e) {};
    \node [salir, below=of e] (f) {};

    \node [multi, below=of b,xshift=4cm,yshift=1.5cm] (g) { };

    \node [reiniciar, left=of e,yshift=1.5cm,xshift=-1cm] (h) {};  

    \draw [l] (a) -- (b);
    \draw [l] (b)-|(c)node [anchor=north, yshift=+2.5cm] {};
    \draw [l] (b)-|(g)node [anchor=north, yshift=+3.2cm] {};
    \draw [l] (e)--(f)node [anchor=west, yshift=1cm] {};
    \draw [l] (d)--(e);
    \draw [l] (e)-|(h);

    \node [xshift=-0.5cm] at (h) (y) {};
    \node [yshift= 1cm] at (b) (z) {};
    \pgfdeclarelayer{background}
    \pgfsetlayers{background,main}
    \begin{pgfonlayer}{background}
      \draw [l,red,ultra thick] (y) |- (z);
    \end{pgfonlayer}

    \draw [dashed,thick] (c) |- (d) node [midway,fill=white] {hello};
    \draw [dashed,thick] (g) |- (d) node [midway,fill=white] {hello};
    \end{tikzpicture}
\end{center}
\end{document}

enter image description here

2

mostly off-topic, but with more correct code syntax and clean code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows, calc, fit, positioning, shapes.geometric}

\tikzset{FC/.style = {% FC as FlowChart
   node distance = 8 mm and 6 mm,
     base/.style = {draw, thick, rounded corners, align=center},
        b/.style = {base, fill=blue!20,  text width=6em, minimum height=4em},
        h/.style = {base, fill=green!20, text width=6em, minimum height=4em},
 pregunta/.style = {base, diamond, fill=yellow!20, text width=6em, inner sep=0pt},
    salir/.style = {base, fill=red!20,   text width=6em, minimum height=2em, inner sep=0pt},
    multi/.style = {base, fill=blue!20,  text width=15em,minimum height=2em, inner sep=5pt},
reiniciar/.style = {base, fill=brown!20, text width=6em, minimum height=2em, inner sep=0pt},
        c/.style = {base, inner sep=0.5cm, dashed},
        l/.style = {draw, -latex', thick}
                    }
        }

\begin{document}
\begin{center}
    \begin{tikzpicture}[FC, auto]
    \node [h] (a) {};
    \node [pregunta, below=of a] (b) {};
    \node [b, below left=of b]   (c) {};
    \node [multi, below right=of b]  (d) {};
    \node [b, below=of b |- c.south] (e) {};
    \node [pregunta, below=of e] (f) {};
    \node [salir, below=of f]    (g) {};
    \node [reiniciar, left=of c |- e] (h) {};
    %
    \draw [l]   (a) edge  (b)
                (e) edge node {no}  (f)
                (f) edge node {yes?}  (g);
    \draw [l]   (b) -| (c) node [above right,midway] {x};
    \draw [l]   (b) -| (d) node [above  left,midway] {y};
    \draw [l,dashed]   (c) |- (e) node [below right,midway] {xxx};
    \draw [l,dashed]   (d) |- (e) node [below  left,midway] {yyy};
    \draw [l]   (f) -| (h) node [below right,midway] {no};
    \draw [l,red]      (h) |- ($(a.south)!0.5!(b.north)$);
    \end{tikzpicture}
\end{center}
\end{document}

enter image description here

  • Thank you very much Zarco, my code was messy. If it is not ordered, it takes many hours. Another thing, can you explain yourself about the meaning of : l/.style = {draw, -latex', thick} And for example, if I want to put the arrow on top of 'y', How can i do?: \draw [l,red] (h) |- (a.north UP 0.25cm) -| (d.north UP 0.25cm)?? Thanks Zarko – Solid Jan 18 '18 at 12:09
  • @Solid, i took names of styles from you. i only change recent (correct) syntax, meanwhile yours is obsolete. arrows over y is matter of math notation: $\vec{y}$, if you mean this. if you like to have edge labels of below them, than you need to change node position from above to below . – Zarko Jan 18 '18 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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