如何旋转箭头并将其引导至流程图中的两个对象之间

如何旋转箭头并将其引导至流程图中的两个对象之间

我怎样才能输出块“proc1”和“dec1”之间的进程“proc3”的箭头?我试过了,\sbRelieryx但无法编译。

\documentclass[border=5mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{schemabloc}
\usetikzlibrary{shapes.geometric, arrows,positioning,circuits}
\begin{document}
    \tikzset{startstop/.style={rectangle, rounded corners, text width=3cm, minimum   height=1cm,text centered, draw=black},
        io/.style={trapezium, trapezium left angle=70, trapezium right 
        angle=110, text width=3cm, minimum height=1cm, text centered, draw=black},
        process/.style={rectangle, text width=3cm, minimum height=1cm, text centered, draw=black},
        decision/.style={diamond, text width=3cm, minimum height=1cm, text centered,draw=black},
        arrow/.style={thick,-stealth}}
    
        \begin{tikzpicture}[node distance=1cm]
            \node (start) [startstop] {Begin};
            \node (proc1) [process, below = of start] {result = $a1$};
            \node (dec1) [decision, below = of proc1] {i < N - 1};
            \node (proc2) [process, below = of dec1] {result += d};
            \node (proc3) [process, below = of proc2] {i++};
            \node (proc4) [process, right of = dec1, xshift=5cm] {return result};
                    %%%%%LINES%%%%%
            \draw [arrow] (start) -- (proc1);
            \draw [arrow] (proc1) -- (dec1);
            \draw [arrow] (dec1) -- (proc2) node[midway,left] {Yes};
            \draw [arrow] (proc2) -- (proc3);
            %\sbRelieryx {proc3} {proc1-dec1}
            \draw [arrow] (dec1) -- (proc4) node[midway,above] {No};
        \end{tikzpicture}
\end{document}

输出:实际产量

应该发生什么:期望输出

答案1

您可以使用该calc库来计算节点之间的坐标。例如,$(proc1.south)!0.5!(dec1.north)$将为您提供两个坐标中间的坐标。

\documentclass[border=5mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{schemabloc}
\usetikzlibrary{shapes.geometric, arrows,positioning,circuits,calc}
\begin{document}
    \tikzset{startstop/.style={rectangle, rounded corners, text width=3cm, minimum   height=1cm,text centered, draw=black},
        io/.style={trapezium, trapezium left angle=70, trapezium right 
        angle=110, text width=3cm, minimum height=1cm, text centered, draw=black},
        process/.style={rectangle, text width=3cm, minimum height=1cm, text centered, draw=black},
        decision/.style={diamond, text width=3cm, minimum height=1cm, text centered,draw=black},
        arrow/.style={thick,-stealth}}
    
        \begin{tikzpicture}[node distance=1cm]
            \node (start) [startstop] {Begin};
            \node (proc1) [process, below = of start] {result = $a1$};
            \node (dec1) [decision, below = of proc1] {i < N - 1};
            \node (proc2) [process, below = of dec1] {result += d};
            \node (proc3) [process, below = of proc2] {i++};
            \node (proc4) [process, right of = dec1, xshift=5cm] {return result};
                    %%%%%LINES%%%%%
            \draw [arrow] (start) -- (proc1);
            \draw [arrow] (proc1) -- (dec1);
            \draw [arrow] (dec1) -- (proc2) node[midway,left] {Yes};
            \draw [arrow] (proc2) -- (proc3);
            \draw [arrow] (proc3) -- ++(-3,0) |- ($(proc1.south)!0.5!(dec1.north)$);
            \draw [arrow] (dec1) -- (proc4) node[midway,above] {No};
        \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容