4

I have two nodes which should be connected by edges, one going from A to B and one from B to A. The problem is, that they do overlap but I want to show them as separate arrows - so one might shift slightly to the right the other slightly to the left. How might achieve this?

(There seems to be a solution in there TikZ parallel Edges between Nodes but the examples are too complex, so I cannot separate the automation stuff from the placing edges side by side stuff.)

minimal example:

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\begin{document}
 \begin{tikzpicture}[->]
    \node (1) {A};
    \node (2) [below of=1] {B};
    \path[every node/.style={font=\sffamily\small}]
    (1) edge node [left] {edge1} (2)
    (2) edge node [right] {edge2} (1)
    ;
  \end{tikzpicture}
\end{document}

result:

enter image description here

  • Gonzalo has answered already, just adding that there have been other similar questions before, e.g. http://tex.stackexchange.com/questions/18078/double-arrow-in-tikz and http://tex.stackexchange.com/questions/35257/how-do-you-get-two-lines-between-nodes-that-have-paths-to-each-other-instead-of – Torbjørn T. May 10 '13 at 22:28

1 Answers1

7

You can introduce some shifting; the code below shows two possibilities; the first one, using xshift, and the second one, using the <name>.<angle> syntax:

\documentclass{article}
\usepackage{tikz}

\begin{document}
 \begin{tikzpicture}[->]
    \node (1) {A};
    \node (2) [below of=1] {B};
    \path[every node/.style={font=\sffamily\small}]
    ([xshift=-2pt]1.south) edge node [left] {edge1} ([xshift=-2pt]1.south|-2.north)
    ([xshift=2pt]2.north) edge node [right] {edge2} ([xshift=2pt]2.north|-1.south)
    ;
 \begin{scope}[xshift=3cm]
    \node (1) {A};
    \node (2) [below of=1] {B};
    \path[every node/.style={font=\sffamily\small}]
    (1.255) edge node [left] {edge1} (1.255|-2.north)
    (2.75) edge node [right] {edge2} (2.75|-1.south)
    ;
  \end{scope}
  \end{tikzpicture}
\end{document}

enter image description here

Gonzalo Medina
  • 505,128