Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How do I draw two parallel arrows having the same domain and the same codomain in a commutative diagram with TikZ? For that matter, how do I draw any sort of parallel paths between two nodes? Do I need to explicitly shift the two paths myself? And if so how?

share|improve this question

3 Answers 3

up vote 8 down vote accepted

In addition to postaction here are two more ways:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \node (A) at (0,0) {$A$};
    \node (B) at (1,0) {$B$};
    \draw[transform canvas={yshift=0.3ex},->] (A) -- (B);
    \draw[transform canvas={yshift=-0.3ex},<-] (A) -- (B);
\end{tikzpicture} 

\begin{tikzpicture}
    \node (A) at (0,0) {$A$};
    \node (B) at (1,0) {$B$};
    \draw[->] (A.10) -- (B.170);
    \draw[<-] (A.350) -- (B.190);
\end{tikzpicture} 

\end{document}

Note that you need to use transform canvas as “normal” transforms leave the nodes fixed. The (A.10) syntax means a point on the boundary of A, 10 degrees counterclockwise from (A.east).

share|improve this answer
    
Perfect. Thanks. –  TikZ User Dec 16 '10 at 3:11
3  
Note the second of these depends on the nodes being the same size. –  Nathan Grigg Sep 3 '12 at 21:43

how about using a postaction?

\begin{tikzpicture}
\draw[postaction={transform canvas={yshift=-2mm},draw}]
[->] (0,0) -- (1,0);
\end{tikzpicture}
share|improve this answer
    
Great, thanks! I don't know exactly how to use a postaction to put different labels on the two paths, but the transform canvas thing does the job for me. –  TikZ User Dec 16 '10 at 3:12
1  
Well, you can put two labels on the path (one below and one above...) –  Yossi Farjoun Dec 16 '10 at 8:33

Likewise, you can use a path to connect the two nodes:

\begin{tikzpicture}[->]
\node (A) at (0,0) {$A$};
\node (B) at (1,0) {$B$};
\path [black] (A.10) edge [bend left] node {} (B.170);
\path [black] (B.190) edge [bend left] node {} (A.350);
\end{tikzpicture} 

This allows use of all the features of path (such as the bend feature).

share|improve this answer
1  
If the arrows are bent, then they aren't parallel, surely. –  Seamus Jan 9 '13 at 11:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.