Tx · LaTeX & TikZ

How to Draw a Double-Headed Arrow in TikZ

Published By the 9to5Science editorial team

At a glance

  1. 1. Use both tips

    Add the <-> option to the TikZ draw command.

  2. 2. Set the endpoints

    Write the path from its starting coordinate to its ending coordinate.

  3. 3. Add a label

    Place a node on the path if you want text between the arrowheads.

To draw an arrow with a head at both ends, put the TikZ option <-> in the square brackets of \draw. The arrowheads point toward both endpoints of the path.

Basic double-headed arrow

\draw[<->] (0,0) -- (4,0);

Here, (0,0) and (4,0) are the endpoints, and -- draws a straight segment between them. The <-> option adds arrowheads at both ends. You can use the same option on a diagonal or curved path; it applies to the path, not just horizontal lines.

Complete compilable example

This document draws a labeled, horizontal double-headed arrow. It uses only the tikz package; no extra TikZ library is needed for the basic <-> style.

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  \draw[<->] (0,0) -- node[midway, above] {$d$} (4,0);
\end{tikzpicture}
\end{document}

The node[midway, above] {$d$} places the label above the center of the segment. Use below instead to put it underneath, or omit the node if you do not need a label.

Choosing different arrowhead shapes

For more control over the tips, load TikZ’s arrows.meta library and specify a tip at each end. For example:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}
  \draw[{Stealth}-{Stealth}, thick] (0,0) -- (4,0);
\end{tikzpicture}
\end{document}

The {Stealth}-{Stealth} option selects a Stealth-style tip at both ends. You can also set tip parameters, such as size, using the arrows.meta syntax. The simpler <-> is convenient when the default arrow style is sufficient; use arrows.meta when you need a particular appearance.

Double arrows on other paths

The same option works for a path made of several segments:

\draw[<->] (0,0) -- (2,1) -- (4,0);

This draws one connected, bent path with a head at its two outer endpoints. It does not add a head at the internal corner. To put arrowheads on each separate segment, draw the segments as separate paths or specify the arrow options for each path.

You can also combine <-> with ordinary drawing options:

\draw[<->, thick, blue] (0,0) -- (4,0);

The arrow option and line appearance can be listed together, separated by commas.

Common mistakes

  • Putting the option after the path: Write \draw[<->] ..., not \draw ... [<->].
  • Using the wrong brackets: TikZ drawing options go in square brackets. The angle brackets in <-> are part of the option’s value; they do not replace the square brackets.
  • Expecting a tip at every bend: A single connected path gets tips at its two ends, not at each intermediate coordinate.
  • Loading a library unnecessarily: The basic <-> form does not require arrows.meta. Load that library only when using its named tips or customization features.

References

  1. TikZ & PGF Manual

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.