我想在另一条路径的中点结束一条路径。我倾向于尝试在偏移量等于节点距离的一半处结束路径d.north
,但我似乎尝试的任何方法都无法编译。这是我目前所拥有的(最终目标是以“此处”结束的“否”路径)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,calc}
\begin{document}
\pagestyle{empty}
% Define block styles
\tikzstyle{box} = [rectangle, draw]
\tikzstyle{line} = [draw, -latex']
\begin{tikzpicture}[node distance = 3cm, auto]
% Place nodes
\node [box] (a) {A};
\node [box, below of=a] (b) {B};
\node [box, below of=b] (c) {C};
\node [box, below of=c] (d) {D};
% Draw edges
\path [line] (a) -- (b);
\path [line] (b) -- (c);
\path [line] (c) -- node [midway, left] {HERE} (d);
\path [line] (a.east) --node [above] {No} +(1,0) |- (d.north);
\end{tikzpicture}
\end{document}
我在路径装饰上看到了一些东西,但我真的不确定如何使用它们,也不确定我是否可以在它们上面结束路径。
答案1
您的代码已经包含一个解决方案(不带calc
库)midway
:!
\documentclass{standalone}
\usepackage{tikz}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\tikzstyle{box} = [rectangle, draw]
\tikzstyle{line} = [draw, -latex']
\begin{document}
\begin{tikzpicture}[node distance = 3cm, auto]
% Place nodes
\node [box] (a) {A};
\node [box, below of=a] (b) {B};
\node [box, below of=b] (c) {C};
\node [box, below of=c] (d) {D};
% Draw edges
\path [line] (a) -- (b);
\path [line] (b) -- (c);
\path [line] (c) -- coordinate[midway](m) (d);
\path [line] (a.east) --node [above] {No} +(1,0) |- (m);
\end{tikzpicture}
\end{document}
答案2
像这样?表示在和(c)!0.5!(d)
中间。(c)
(d)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,calc}
\begin{document}
\pagestyle{empty}
% Define block styles
\tikzstyle{box} = [rectangle, draw]
\tikzstyle{line} = [draw, -latex']
\begin{tikzpicture}[node distance = 3cm, auto]
% Place nodes
\node [box] (a) {A};
\node [box, below of=a] (b) {B};
\node [box, below of=b] (c) {C};
\node [box, below of=c] (d) {D};
% Draw edges
\path [line] (a) -- (b);
\path [line] (b) -- (c);
\path [line] (c) -- node [midway, left] {HERE} (d);
\path[line] let \p1 = ( $(c)!0.5!(d) $ ) in (a.east) --node [above] {No} +(1,0) |- +(0,\y1);
\end{tikzpicture}
\end{document}