Tx · LaTeX & TikZ

Why Does an Arrow Disappear in a TikZ Draw Command?

Published By the 9to5Science editorial team

At a glance

  1. 1. Check the endpoints

    A named node used with -- can make the path end at the node center.

  2. 2. Use node-aware paths

    Connect named nodes with to, which stops the path at their borders.

  3. 3. Draw nodes over edges

    Define nodes first, then draw edges so node fills do not cover arrowheads.

  4. 4. Check the arrow style

    If the path is very short or closed, adjust its length or define an open path.

If an arrow appears on some TikZ edges but vanishes on others, first check where each path ends and which objects are drawn on top. A line from a node center to another node center can put its arrowhead inside the target circle. If the circle is drawn after the path, its fill can hide the tip.

For connections between named nodes, use TikZ’s to operation or specify shape-border anchors. The example below shows both the problem and a reliable fix.

Connect to the node border

When you use a node name as a coordinate in a straight -- path, the coordinate refers to the node’s center. For example:

\draw[->] (A) -- (B);

If B is a filled circle, the arrowhead is placed at its center. If the circle is drawn after the path, it can cover the tip, making the arrow look missing or shorter than expected.

The to operation handles named nodes differently: it finds where the path meets the node’s border. For a straight connection, write:

\draw[->] (A) to (B);

Here is a complete example you can compile. The first arrow uses -- and ends at the center of B; the second uses to and ends at its border.

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  % Draw the center-to-center test path before the node shapes.
  \coordinate (Apos) at (0,0);
  \coordinate (Bpos) at (3,0);
  \draw[->, red] (Apos) -- (Bpos);

  % These filled nodes cover the red path at their centers.
  \node[circle, draw, fill=white, minimum size=12mm] (A) at (Apos) {A};
  \node[circle, draw, fill=white, minimum size=12mm] (B) at (Bpos) {B};

  % This arrow is drawn afterward and ends at the node borders.
  \draw[->, blue, thick] (A) to[bend left=30] (B);
\end{tikzpicture}
\end{document}

The red path is drawn before the node shapes, so B’s fill covers its center endpoint. The blue path is drawn afterward and uses to, so it ends at the node borders without crossing the nodes’ interiors. In your own diagram, remove the red test path and choose the style you want for the remaining edge.

Specify the anchors yourself

For a straight horizontal connection, explicit anchors are another dependable option:

\draw[->] (A.east) -- (B.west);

This starts at the east side of A and ends at the west side of B. Use anchors that match the layout: for example, .north and .south for a vertical connection. Explicit anchors are useful when you need precise control, but they do not automatically adjust to a changed direction. For angled or moving connections, to is often more convenient.

Why arrows can look inconsistent

An arrowhead is drawn at the end of a directed path. Whether you can see it depends on the endpoint and the drawing order:

  • The endpoint is inside a node. With a center-to-center -- path, a filled target node can cover the tip if the node is drawn after the path. If the path is drawn later, it can instead overlay the node.
  • A later object covers the arrow. TikZ draws paths and nodes in order. To have opaque nodes mask portions of an edge, draw the edge first and the nodes afterward. Draw edges afterward only when you want them to appear over the nodes.
  • The path is very short. The arrowhead takes up part of the path, leaving little visible line. Move the nodes farther apart or use a smaller arrow tip.
  • The path direction is reversed. -> places a tip at the path’s end, not at whichever endpoint looks like the destination in your diagram. Reverse the coordinates if the tip is on the wrong end.

If the arrow follows a circle

A complete circle is a closed path: it has no distinct beginning and end for an arrow to indicate. To show direction around part of a circle, draw an open arc with a specified start and end angle, for example:

\draw[->] (30:1.5) arc (30:300:1.5);

This draws an arc of radius 1.5 from 30 degrees to 300 degrees and puts the arrowhead at the end. If the arrow should appear at a particular point on the arc, choose the start and end angles accordingly.

Common mistakes

  • Using shorten >= to fix a center endpoint. Shortening can move the arrowhead away from the endpoint, but it does not reliably identify a node’s border. Use to or an explicit anchor for that.
  • Assuming -> means both directions. It makes a one-way arrow. For tips at both ends, use <->.
  • Expecting a closed circle to show a clear direction. Use an open arc when you need an arrow that indicates travel around a curve.
  • Ignoring drawing order. An opaque node drawn after an edge can cover it; this is often intentional. Draw edges first and nodes afterward when the nodes should mask edge interiors. Draw edges afterward only when they should overlie nodes.

References

  1. PGF/TikZ Manual: Paths and To Operations
  2. PGF/TikZ Manual: Nodes and Shapes

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