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

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

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.