1

How can I draw two horizontal arrow lines to each direction from one rectangle to another. Rectangles are of different heights and I want to keep both arrows horizontal.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning}
\usetikzlibrary{calc,decorations.markings}

\begin{document}

\begin{figure}
    \centering  
    \begin{tikzpicture}[
        node distance   = 1cm and 2cm,
        document/.style = {rectangle, draw, rounded corners, fill=orange!10, minimum width=1cm, minimum height=1cm, align=center},
        document2/.style    = {rectangle, draw, rounded corners, fill=orange!10, minimum width=1cm, minimum height=4cm, align=center},      arrow/.style = {thick,-stealth}
    ]

    \node   (a1)    [document]                                          {abc};
    \node   (a2)    [document2, right=4cm of a1]                        {def};
    \path [draw, arrow] (a1)        --  node    [text width=2cm, midway, anchor=north]  {going left} (a2);  

    \end{tikzpicture}
\end{figure}
\end{document}

enter image description here

1
2

Following solution is a little more verbose than Zarko's one, but it allows to easily control the distance between parallel lines.

\documentclass[margin=2]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                positioning}

\begin{document}
    \begin{tikzpicture}[
node distance = 1cm and 4cm,
     N/.style = {draw, rounded corners, fill=orange!10, 
                 minimum height=#1, minimum width=1cm},
    ar/.style = {draw=red, thick, -Straight Barb}
    ]
\node (a1)  [N=10mm]                {abc};
\node (a2)  [N=40mm, right=of a1]   {def};
%
\draw[ar] ([yshift=1mm]a1.east) coordinate (aux1)  --  (aux1  -| a2.west);
\draw[ar] ([yshift=-1mm]a2.west) coordinate (aux2) --  (aux2 -| a1.east);
    \end{tikzpicture}
\end{document}

enter image description here

Update: Adding labels above and below arrows

\documentclass[margin=2]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                positioning}

\begin{document}
    \begin{tikzpicture}[
node distance = 1cm and 4cm,
     N/.style = {draw, rounded corners, fill=orange!10, 
                 minimum height=#1, minimum width=1cm},
    ar/.style = {draw=red, thick, -Straight Barb}
    ]
\node (a1)  [N=10mm]                {abc};
\node (a2)  [N=40mm, right=of a1]   {def};
%
\draw[ar] ([yshift=1mm]a1.east) coordinate (aux1) node[above right, red]{going right} --  (aux1  -| a2.west);
\draw[ar] ([yshift=-1mm]a2.west) coordinate (aux2) node[below left, red]{going left} --  (aux2 -| a1.east);
    \end{tikzpicture}
\end{document}

enter image description here

4
  • Thank you very much. Can you also let us know how can we put text such as "going left" and "going right" aligned to left and right of the arrow lines?
    – pba
    Jan 9 at 15:37
  • @pba I've updated the answer with desired labels
    – Ignasi
    Jan 9 at 19:48
  • Many thanks. I was experimenting with the positioning of labels, "above left", "above right", "below left", "below right" works but what can we use it to place them at centre? and may be after some designated space (say 4mm)?
    – pba
    Jan 10 at 2:06
  • This may needs to be a seperate thread. I raised this question in another thread tex.stackexchange.com/questions/578274/…. Request you to please look into the same as well.
    – pba
    Jan 10 at 4:52
2

Edit: added are edges labels. For them is used quotes linrary:

enter image description here

\documentclass[margin=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                positioning,
                quotes}

\begin{document}
    \begin{tikzpicture}[
node distance = 1cm and 4cm,
     N/.style = {draw, rounded corners, fill=orange!10, 
                 minimum height=#1, minimum width=1cm},
    ar/.style = {draw=red, thick, -Straight Barb},
every edge quotes/.append style = {font=\footnotesize}
                        ]
\node (a1)  [N=10mm]                {abc};
\node (a2)  [N=40mm, right=of a1]   {def};
%
\draw[ar] (a1.10)  to["going right"]  (a1.10  -| a2.west);
\draw[ar] (a2.190) to["going  left"]  (a2.190 -| a1.east);
    \end{tikzpicture}
\end{document}
1
  • Thank you very much. Can you also let us know how can we put text such as "going left" and "going right" aligned to left and right of the arrow lines?
    – pba
    Jan 9 at 15:42

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.