Tikz 中的箭头位置

Tikz 中的箭头位置

我想绘制下面的图片,但我在绘制箭头时遇到了问题,就是右边的箭头,我不知道如何定位箭头。有人能帮我吗? 在此处输入图片描述

以下是 MWE:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,calc}
\tikzstyle{box} = [draw, rectangle, rounded corners, thick, node distance=5.3em, text width=8em, text centered, minimum height=3.5em]
\tikzstyle{container} = [draw, rectangle,thick, node distance=5.3em, text width=8em, text centered, minimum height=3.5em ]
\tikzstyle{line} = [draw, thick, -latex']

\begin{document}
\begin{tikzpicture}[auto]
    \node [box] (User) {User \\ Requirements};
    \node [container, below of=User] (Informal) {Informal \\ Specification};
    \node [container, below of=Informal] (Formal) {Formal \\ Specification};
    \node [container, below of=Formal] (Protocol) {Protocol \\ Verfication};
 \node [container, below of=Protocol] (Implementation) {Implementation \\ Development};
     \node [container, below of=Implementation] (Conformance) {Conformance \\ Testing};
  \node [container, below of=Conformance] (Interoperability) {Interoperability \\ Testing};
   \node [box, below of=Interoperability] (Maintenance) {Maintenance};

    \path [line] (User) -- (Informal);
    \path [line] (Informal) -- (Formal);
    \path [line] (Formal) -- (Protocol);
 \path [line] (Protocol) -- (Implementation);
 \path [line] (Implementation) -- (Conformance);
\path [line] (Conformance) -- (Interoperability);
  \path [line] (Interoperability) -- (Maintenance);

\end{tikzpicture}
\end{document}

答案1

您的流程图相对简单...因此可以简化它的代码:使用chains可以实现以下功能的库:

  • 流程图中节点的简单定位
  • 使用提供的节点名称chains
  • 使用宏join绘制节点之间的连接线

除此之外,在绘图中使用:

  • 对于反馈回路箭头定义了两个辅助坐标
  • 用于定位的是positioning库和它的语法
  • \tikzstyle是定义tikz绘图元素样式的过时方法。相反,它是姆韦下面用于tikzset定义样式

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, calc, chains, positioning}
\tikzset{
base/.style = {rectangle, rounded corners, draw, thick,
               text width=8em, minimum height=3.5em, align=flush center,
               on chain=A, join=by LA},
 box/.style = {base, rounded corners},
  EL/.style = {% Edge Labels
               font=\footnotesize, align=left},
  LA/.style = {% Line with Arrowhead
               thick, -Stealth}
        }
\begin{document}
    \begin{tikzpicture}[
  node distance = 6mm and 15mm,
    start chain = A going below,
                        ]
\node [box]     {User Requirements};            % A-1
\node [base]    {Informal Specification};
\node [base]    {Formal Specification};
\node [base]    {Protocol Verfication};         % A-4
\node [base]    {Implementation Development};
\node [base]    {Conformance Testing};
\node [base]    {Interoperability Testing};
\node [box]     {Maintenance};                  % A-8
%
\draw [LA]  (A-4.east) -- ++ (1.5,0) |-
            ($(A-2)!0.45!(A-3)$) node[EL,pos=0.25,right]{Errors\\ Detected};
% auxilary coordinates
\coordinate[right=of $(A-4.east)!0.45!(A-5.east)$] (a1);
\coordinate[right=of a1] (a2);
\draw [LA]  (A-6) -| (a1) node[EL,pos=0.75,right] {Errors\\ Detected};
\draw [LA]  (A-7) -| (a2) node[EL,pos=0.75,right] {Errors\\ Detected};
\draw [LA]  (a2)  -- (a2 -| A-5);

\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

这是反复试验的过程,因此可能不是您想要的,但至少它产生了所需的结果:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,calc}
\tikzstyle{box} = [draw, rectangle, rounded corners, thick, node distance=5.3em, text width=8em, text centered, minimum height=3.5em]
\tikzstyle{container} = [draw, rectangle,thick, node distance=5.3em, text width=8em, text centered, minimum height=3.5em ]
\tikzstyle{line} = [draw, thick, -latex']

\begin{document}
\begin{tikzpicture}[auto]

    \node [box] (User) {User \\ Requirements};
    \node [container, below of=User] (Informal) {Informal \\ Specification};
    \node [container, below of=Informal] (Formal) {Formal \\ Specification};
    \node [container, below of=Formal] (Protocol) {Protocol \\ Verfication};
    \node [container, below of=Protocol] (Implementation) {Implementation \\ Development};
    \node [container, below of=Implementation] (Conformance) {Conformance \\ Testing};
    \node [container, below of=Conformance] (Interoperability) {Interoperability \\ Testing};
    \node [box, below of=Interoperability] (Maintenance) {Maintenance};

    \path [line] (User) -- (Informal);
    \path [line] (Informal) -- (Formal);
    \path [line] (Formal) -- (Protocol);
    \path [line] (Protocol) -- (Implementation);
    \path [line] (Implementation) -- (Conformance);
    \path [line] (Conformance) -- (Interoperability);
    \path [line] (Interoperability) -- (Maintenance);

    \draw [->] (1.5,-5.5) -- (3,-5.5) -- (3,-2.75) -- (0,-2.75);
    \node [align=left] at (3.75,-4) {Errors\\ detected};
    \draw [->] (1.5,-9.25) -- (3,-9.25) -- (3,-6.5);
    \node [align=left] at (3.75,-8) {Errors\\ detected};
    \draw [->] (1.5,-11) -- (4.75,-11) -- (4.75,-6.5) -- (0,-6.5);
    \node [align=left] at (3.5,-11.5) {Errors\\ detected};

\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容