我有这个;
\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}
我想要这个,箭头指向钻石的顶部:
我该怎么做?
谢谢
答案1
我将其添加到您的代码中:
\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}
我不得不用在节点pgfonlayer
后面画箭头reiniciar
。
完整代码:
\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}
答案2
大部分内容与主题无关,但代码语法更正确,代码也更干净:
\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}