Tikz 中箭头的位置

Tikz 中箭头的位置

我想画出像这样的箭头,

在此处输入图片描述

但我得到这样的,我不知道如何在 tikz 中定位箭头

在此处输入图片描述

请你帮助我好吗?

这是我的 MWE:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\begin{document}
    \begin{tikzpicture}
    \tikzstyle{box}=[draw,text width=8em, minimum height=7.5em,thin, align=flush center]
    % The comment style 
\tikzstyle{comment}=[rectangle, inner sep= 5pt, text width=4cm, node distance=0.25cm]
\tikzstyle{box1}=[draw,text width=11em, minimum height=3.5em,thin,align=flush center]
\tikzstyle{line}=[draw, thick, -latex']
        \node (1) [box] {\textbf{Customer}};
        \node (2) [box,right=30mm of 1] {\textbf{Merchant}};
        \node (3) [box1] at (3.5,-3)  {\textbf{Intermediation Server}};
        \node (4) [box1] at (3.5,-5)  {\textbf{Netbill's Bank}};
        \node (5) [box] at (0.5,-8)  {\textbf{Customer's Bank}};
        \node (6) [box] at (6.5,-8)  {\textbf{Merchant's Bank}};
        \node [comment, text width=3cm] at (1.5,-10.7)   { 1. Request quote\\
            2. Present quote\\
            3. Accept quote\\
            4. Deliver goods };

        \node [comment, text width=4cm] at (5.5,-10.9)   { 5. Send electronic payement order (EPO)\\
            6. Send EPO and key\\
            7. Send receipt\\
            8. Send receipt  };
        %arrows
         \draw [-latex,thick] (1.north) --  node[right,above] {(1)}(2.north) ;
         \draw [-latex,thick] (2) --  node[left,above] {(2)}(1) ;
          \draw [-latex,thick] (2.south west) --  node[left] {(6)}(3) ;
           \draw [-latex,thick] (3.north east) --  node[right] {(7)}(2) ;
        \draw[latex'-latex',thick]  (3) -- (4);
        \draw[latex'-latex',thick] (4.west) --  node [left] {Account funding} (5);
        \draw [-latex,thick] (4) --  node[left,below] {Batch payment}(6) ;

    \end{tikzpicture}
\end{document}

答案1

您可以使用|--|绘制直角线,例如

\draw[latex'-latex',thick] (4.west) -|  node [left] {Account funding} (5);

将修复您的资金箭头。此外,我尝试使和的边缘(6)平行(7),我已修复箭头的端点(1),并将和的箭头向下移动(1)一点(2)yshift=-7mm因为我认为这看起来更好:

在此处输入图片描述

完整代码如下:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\begin{document}
    \begin{tikzpicture}
    \tikzstyle{box}=[draw,text width=8em, minimum height=7.5em,thin, align=flush center]
    % The comment style
\tikzstyle{comment}=[rectangle, inner sep= 5pt, text width=4cm, node distance=0.25cm]
\tikzstyle{box1}=[draw,text width=11em, minimum height=3.5em,thin,align=flush center]
\tikzstyle{line}=[draw, thick, -latex']
        \node (1) [box] {\textbf{Customer}};
        \node (2) [box,right=30mm of 1] {\textbf{Merchant}};
        \node (3) [box1] at (3.5,-3)  {\textbf{Intermediation Server}};
        \node (4) [box1] at (3.5,-5)  {\textbf{Netbill's Bank}};
        \node (5) [box] at (0.5,-8)  {\textbf{Customer's Bank}};
        \node (6) [box] at (6.5,-8)  {\textbf{Merchant's Bank}};
        \node [comment, text width=3cm] at (1.5,-10.7)   { 1. Request quote\\
            2. Present quote\\
            3. Accept quote\\
            4. Deliver goods };

        \node [comment, text width=4cm] at (5.5,-10.9)   { 5. Send electronic payement order (EPO)\\
            6. Send EPO and key\\
            7. Send receipt\\
            8. Send receipt  };
        %arrows
         \draw [-latex,thick] ([yshift=-7mm]1.north east) --  node[right,above] {(1)}([yshift=-7mm]2.north west) ;
         \draw [-latex,thick] ([yshift=-7mm]2.west) --  node[left,above] {(2)}([yshift=-7mm]1.east) ;
          \draw [-latex,thick] (2.south west) --  node[left] {(6)}([xshift=5mm]3.north) ;
           \draw [-latex,thick] (3.north east) --  node[right] {(7)}(2.south) ;
        \draw[latex'-latex',thick]  (3) -- (4);
        \draw[latex'-latex',thick] (4.west) -|  node [left] {Account funding} (5);
        \draw [-latex,thick] (4) |-  node[left,below] {Batch payment}(6) ;

    \end{tikzpicture}
\end{document}

您可以调整我移动箭头的方式(1)(2)如果您想要在“客户”和“商家”之间添加更多箭头

默认情况下,您可以使用A.northA.eastA.southA.westA.north east...A.south west来定位边的端点到节点 和从节点 开始的位置A。您还可以使用

\draw(A) to[out=70, in=110] (B);

控制弯曲箭头的出口和入口角度。如果您需要更好地控制箭头的位置,请查看positioning library- 请参阅当前 tikz/pgf 手册的第 17.5.3 节(第 229 页)。

相关内容