16

Is it possible to get TikZ-arrows to draw double-headed arrows?

What I'm looking for is a way to achieve

\draw[-triangle 90 triangle 90] (A) -- (B);

and the open triangle equivalent, in the way TikZ would normally read

\draw[->>] (A) -- (B);
DavidHume
  • 263

4 Answers4

14

See the Section 74 (also 23) of PGF documentation (mine is version 2.10) to obtain a lot of arrow tips.

Just put on preamble

\usetikzlibrary{arrows}
\pgfarrowsdeclarecombine{twotriang}{twotriang}%
{triangle 90}{triangle 90}{triangle 90}{triangle 90}

and then you can use \draw[twotriang-twotriang] (0,0) -- (2,0);

Here is the output.

enter image description here

Here is a part of the documentation

enter image description here

Cathode
  • 330
  • 2
  • 12
Sigur
  • 37,330
  • Great, thanks! This has worked very well. I'd already looked at all the documentation you suggested, but thanks for posting it anyway. – DavidHume Jun 24 '13 at 13:59
12

A possibility is to use postactions and shorten

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

\begin{tikzpicture}[font=\sffamily\small]
\draw[-triangle 90, postaction={draw, shorten >=4pt, -triangle 90}] (0,0) -- (1,0);
\draw[-triangle 90, postaction={draw, shorten >=-4pt, -triangle 90}] (0,-.5) -- (1,-.5);
\end{tikzpicture}

\end{document}

enter image description here

In the first case the second head is added before the original one, in the second is added after. This is controlled by the positive or negative shorten value.

If you want to typle less you can do:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

\tikzset{dblb/.style={postaction={draw,shorten >=4pt, -triangle 90}}}
\tikzset{dbla/.style={postaction={draw,shorten >=-4pt, -triangle 90}}}
\begin{tikzpicture}[font=\sffamily\small] 
\draw[-triangle 90,dblb] (0,0) -- (1,0);
\draw[-triangle 90,dbla] (0,-.5) -- (1,-.5);
\end{tikzpicture}

\end{document}

same result.

d-cmst
  • 23,095
  • -1. It's misleading. – Leo Liu Jun 24 '13 at 13:59
  • 3
    @LeoLiu I prefer this way because it's actually more powerful than other methods, you can have like five heads, placed wherever you want and you could also have heads with different shapes. – d-cmst Jun 24 '13 at 14:17
11

It is easy to use ->> if we set >=triangle 90 first.

An example:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

\tikz \draw[>=triangle 90, ->>]
  (0,0) -- (2,0);

\end{document}

enter image description here

Leo Liu
  • 77,365
7

With PSTricks. Just for fun!

\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
\begin{pspicture}(2,2)
    \psline{->>}(1,1)
\end{pspicture}
\end{document}

enter image description here

The look-up table is given as follows.

enter image description here