# Drawing multiple double headed arrows

I used the following code to draw multiple double-headed arrows.

When I used one single \draw command, only the last line has double-headed arrow.

But when I used multiple \draw commands, all lines have double-headed arrows. Why was that?

\documentclass{beamer}
\usepackage{verbatim}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{arrows}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{tikzpicture}[transform shape]
\draw [ultra thick, blue, latex' -latex'] (0,2) -- +(0:1.2cm) (2,2) -- +(0:1.2cm) (4,2) -- +(0:1.2cm);

\draw [ultra thick, blue, latex' -latex'] (0,1) -- +(0:1.2cm);
\draw [ultra thick, blue, latex' -latex']  (2,1) -- +(0:1.2cm);
\draw [ultra thick, blue, latex' -latex'] (4,1) -- +(0:1.2cm);
\end{tikzpicture}
\end{frame}
\end{document}


• If you replace in the first draw command -- by edge, i.e. \draw [ultra thick, blue, latex' -latex'] (0,2) edge +(0:1.2cm) (2,2) edge +(0:1.2cm) (4,2) -- +(0:1.2cm);, you'll get the same result as in the second row, – marmot Oct 27 '18 at 18:32
• Thank you very much. Can you please tell me why? – Hany Oct 27 '18 at 18:40

If you replace in the first \draw command the first two -- by edge, i.e. \draw [ultra thick, blue, latex' -latex'] (0,2) edge +(0:1.2cm) (2,2) edge +(0:1.2cm) (4,2) -- +(0:1.2cm);, you'll get the same result as in the second row.

\documentclass{beamer}
\usepackage{verbatim}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{arrows}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{tikzpicture}[transform shape]
\draw [ultra thick, blue, latex'-latex'] (0,2) edge +(0:1.2cm) (2,2) edge
+(0:1.2cm) (4,2) -- +(0:1.2cm);

\draw [ultra thick, blue, latex' -latex'] (0,1) -- +(0:1.2cm);
\draw [ultra thick, blue, latex' -latex']  (2,1) -- +(0:1.2cm);
\draw [ultra thick, blue, latex' -latex'] (4,1) -- +(0:1.2cm);
\end{tikzpicture}
\end{frame}
\end{document}


The results are different since in the first row of your example you have just one path, and instruct TikZ to insert arrow heads at its start and end. On the other hand, an edge is a new path, so each of these edges will have arrow heads at their start and end positions. I personally do not work with edges that much because I find them slightly confusing. To see that, replace all -- by edges (as I did in the first version of my comment),

\draw [ultra thick, blue, latex'-latex'] (0,2) edge +(0:1.2cm) (2,2) edge +(0:1.2cm) (4,2) edge +(0:1.2cm);


Then you'll get

There is an excess vertical arrow, which you noted yourself. This is because there is essentially an empty path consisting just of one point, (4,2). Why this is the point TikZ takes the path to be, and not, say, (0,2) I do not 100% understand, but this is the reason why I do not like to use edges too much and think your serious of \draw commands is cleaner.

• @Hany You're welcome! – marmot Oct 27 '18 at 19:01