[Tex/LaTex] Draw two lines between two nodes with tikz

tikz-pgf

I have two nodes

\node (A) {A};
\node [below=of A] (B) {B};

I can draw a line between them with

\draw (A) -- (B);

But I need two lines between them. If I'm using

\draw (A) -- (B);
\draw (B) -- (A);

it will draw the two lines on top of each other. Can I make some space between them? I have also tried (A.west) -- (B.west) but that's too far to the left. The two lines should be quite close to each other.

Best Answer

There are several ways, e.g.:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}
  \node (A) {A};
  \node [below=of A] (B) {B};
  \draw[transform canvas={xshift=-1.5pt}] (A) -- (B);
  \draw[transform canvas={xshift=1.5pt}] (B) -- (A);
\end{tikzpicture}
\end{document}

Result

Or the shift can be added to the start and end points:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}
  \node (A) {A};
  \node [below=of A] (B) {B};
  \foreach \s in {-1.5pt, 1.5pt} {
    \draw ([xshift=\s]A.south) -- ([xshift=\s]B.north);
  }
\end{tikzpicture}
\end{document}

Or a double line can be used, see the answer of Alenanno.