Tx · LaTeX & TikZ

How to Draw a Half Arrow in TikZ

Published By the 9to5Science editorial team

At a glance

  1. 1. Choose the meaning

    Decide whether the arrowhead should sit midway along a line or whether the arrow itself should cover only half the line.

  2. 2. Load the libraries

    Use arrows.meta for the Stealth tip and decorations.markings to place a tip at an interior point.

  3. 3. Add the arrowhead

    Apply a marking at position 0.5 to put the tip halfway along the directed path.

  4. 4. Check its direction

    The arrowhead points in the direction the path is drawn; reverse the endpoints to reverse it.

A “half arrow” can mean either an arrowhead placed halfway along a line, or an arrow that covers only half of a longer line. The first is often what people want in TikZ: draw the full line, then add a directed arrowhead at its midpoint. The example below uses the decorations.markings library to do that.

Put an arrowhead at the midpoint

Use a marking at position 0.5. TikZ measures this position along the path, so 0.5 means halfway from the path’s start to its end.

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{arrows.meta,decorations.markings}

\tikzset{
  mid arrow/.style={
    postaction={decorate},
    decoration={
      markings,
      mark=at position 0.5 with {\arrow{Stealth}}
    }
  }
}

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

The postaction={decorate} applies the marking after TikZ draws the line. mark=at position 0.5 selects its midpoint, and \arrow{Stealth} places a Stealth arrow tip there. The arrows.meta library provides the Stealth tip style; decorations.markings provides the path marking.

The path is directed: in (0,0) -- (4,0), it runs left to right, so the arrow points right. Reverse the endpoints to point it left:

\draw[thick, mid arrow] (4,0) -- (0,0);

You can reuse the mid arrow style on straight or curved paths. The marking is placed halfway along the path’s length, not necessarily at the midpoint of its bounding box.

Draw an arrow on only half the line

If “half arrow” means that just one half of the line should be an arrow, split the drawing into two segments. For example, this draws a plain line from 0 to 2 and an arrow from 2 to 4:

\draw[thick] (0,0) -- (2,0);
\draw[thick, -{Stealth}] (2,0) -- (4,0);

The arrow tip is at the end of the second segment. To put the arrow over the first half instead, reverse which segment receives the arrow style:

\draw[thick, -{Stealth}] (0,0) -- (2,0);
\draw[thick] (2,0) -- (4,0);

This approach is useful when you want the arrow shaft itself to begin or end at a particular point. By contrast, the midpoint marking method leaves one continuous line and overlays an arrowhead on it.

Adjust the arrow position and appearance

Change 0.5 to another fraction between 0 and 1 to move the arrowhead. For instance, 0.25 places it one quarter of the way from the start of the path. The fraction is measured in the direction the path is drawn.

You can also change the line width or arrow tip. For example, use -{Latex} on an ordinary arrow segment to select the Latex tip from arrows.meta, or set a line style such as very thick. Keep the arrow-tip library loaded when using these named tip styles.

Common mistakes

  • Using -{Stealth} on the full line: This puts the arrowhead at the path’s endpoint, not at its midpoint. Use a marking for an interior arrowhead.
  • Forgetting decorations.markings: Without that library, TikZ will not recognize the marking decoration.
  • Reversing the intended direction: The arrow follows the direction from the first coordinate to the second. Swap the endpoints to reverse it.
  • Assuming 0.5 means halfway across the page: It means halfway along the path. On a bent or curved path, that point may not be halfway between the extreme coordinates.
  • Drawing two overlapping arrow styles: If you add an ordinary endpoint arrow to the same path as the midpoint marking, you will get two arrowheads. Use only the style that matches the intended result.

References

  1. PGF/TikZ Manual

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