1

I want to draw the arrows like this picture,

enter image description here

but I get like this, I don't know how to position the arrows in tikz

enter image description here

Could you please help me?

Here's my 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
    Use north west and north east instead of north. You could use the calc library and then \draw [-latex,thick] ($(2.north west)+(0,-1.5em)$) -- node[above,pos=0.9] {(2)}($(1.north east)+(0,-1.5em)$) ;, \draw [-latex,thick] ($(1.north east)+(0,-3em)$) -- node[above,pos=0.9] {(3)}($(2.north west)+(0,-3em)$) ; With 1.5em steps.... – Bobyandbob Nov 8 '17 at 15:01
3

You can use |- and -| to draw lines with right angles in them so, for example

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

will fix your funding arrow. In addition, I have tried to make the edges for (6) and (7) parallel, I have fixed the end-points for arrow (1) and I have moved the arrows for (1) and (2) down a little using yshift=-7mm as I think this looks much nicer:

enter image description here

Here's the full code:

\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}

You can adapt how I moved arrows(1) and (2) if you want more arrows between the "Customer" and Merchant"

By default you can use A.north, A.east, A.south, A.west, A.north east, ..., A.south west to position the end points of edges to and from node A. You can also use

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

to control the exit and entry angles for curved arrows. If you need more control over the placement of the arrows have a look at the positioning library -- see section 17.5.3 of the current tikz/pgf manual (page 229).

  • perfect thanks for the explanation, I succeed to draw the picture as I want it – Nousa Nov 8 '17 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.