18

I have an ellipse in a TikZ diagram and I would like to indicate a direction using an arrow head, but do not wish to draw the path leading up to the arrow head.

I currently have

\draw[->] (0,2) arc (90:45:1 and 2);
\draw (0,0) ellipse (1 and 2);

but I'd like the arc leading up to the arrow to be invisible (so it is not redrawing over the ellipse), so that it's just the head showing.

What is the best way to achieve this?

5 Answers 5

11
+100

You can use path decorations:

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}[decoration={
  markings,
  mark=at position 0.2 with {\arrow{<}}}
]
  \draw[postaction={decorate}] (0,0) ellipse (1 and 2);
\end{tikzpicture}

\end{document}
11

(Tested with TikZ 3.0.1a)

You can use the tips key to configure drawing of arrow tips. The initial value of the tips key is on draw, so initially, arrow tips are only drawn when the path itself is drawn, too. But you can set the tips key to true to draw arrow tips even for undrawn paths.

\path[tips, ->] (0,2) arc (90:45:1 and 2);
\draw (0,0) ellipse (1 and 2);

See Chapter 16.2 (Where and When Arrow Tips Are Placed) of the TikZ and PGF Manual.

2
  • 2
    This is perfect.
    – The Vee
    Commented Nov 22, 2020 at 21:59
  • This should be the accepted answer!
    – CarLaTeX
    Commented Nov 18, 2021 at 7:43
9

Tested with TikZ 3.0:

  • load the arrows.meta library instead of arrows
  • add draw opacity=0 as option to \draw, but not to the arrow, such as >={LaTeX[]}

The tail will be completely opaque, i.e. will not be shown, only the head will be visible.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
  \draw[->,>={LaTeX[]},draw opacity=0] (0,2) arc (90:45:1 and 2);
  %\draw (0,0) ellipse (1 and 2);% commented out to see only the tip
\end{tikzpicture}
\end{document}

Arrow tip without tail

3
  • Shows only a blank page. Texlive 2019.
    – vonbrand
    Commented Feb 22, 2020 at 22:13
  • @vonbrand Just re-tested: it shows an arrow on an otherwise blank page, as expexted. Did you zoom in and look? It's very small. I checked with an older TeX Live though, on my business laptop where I didn't install TL 2019 yet.
    – Stefan Kottwitz
    Commented Feb 23, 2020 at 2:04
  • It does not work, it seems to work only with filled arrows but it draws only the filler, not the border. With other kind of arrows it doesn't draw anything.
    – CarLaTeX
    Commented Nov 18, 2021 at 7:42
6

Any easy to type but slightly hackish solution is to use a very small path for the arrow:

\begin{tikzpicture}
    \draw (0,0) ellipse (1 and 2);
    \draw[->] (0,0) ++ (45:1 and 2) arc (45:44.9:1 and 2);
\end{tikzpicture}

To get a flexible "clean" solution one can use markings:

\usetikzlibrary{decorations.markings}
\begin{tikzpicture}
    \draw (0,0) ellipse (1 and 2);
    \draw[decoration={markings,mark=at position 1 with {\arrow{>}}},decorate]
        (0,2) arc (90:45:1 and 2);
\end{tikzpicture}

The marking can also be directly applied to the ellipse (which is drawn counterclockwise from 0 degrees):

\begin{tikzpicture}
    \draw [decoration={markings,mark=at position 1/8 with {\arrowreversed{>}}},postaction={decorate}] 
        (0,0) ellipse (1 and 2);
\end{tikzpicture}

See Section 27.6 of the TikZ manual for the general syntax of the mark option.

2
  • Yes, that should work, but it doesn't seem like a clean solution (not that I currently have one). Another non-clean solution is to just remove the ellipse command and get tikz to draw an arc the entire perimeter of the ellipse, but I'd like to know a general solution to my problem of drawing arrow heads.
    – bryn
    Commented Aug 7, 2010 at 9:52
  • I added a second solution that is more flexible.
    – Caramdir
    Commented Aug 7, 2010 at 10:12
2

You can do this very simply in plain Metapost. The arrowhead macro takes an arbitrary path as an argument, and returns the path of an arrowhead at the end of the given path.

Using appropriate subpath commands you can position an arrowhead anywhere you like along a path. The standard arrowhead produces a rather solid looking arrow, so you might prefer the open or curly versions included below.

An ellipse with arrowheads

prologues := 3;
outputtemplate := "%j%c.eps";

vardef open_arrowhead expr p =
  save q,e; path q; pair e;
  e = point length p of p;
  q = gobble(p shifted -e cutafter makepath(pencircle scaled 2ahlength))
    cuttings;
  (q rotated .5ahangle & reverse q rotated -.5ahangle)  shifted e
enddef;

vardef curly_arrowhead expr p =
  save q,e; path q, q'; pair e;
  e = point length p of p;
  q = gobble(p shifted -e cutafter makepath(pencircle scaled 2ahlength))
    cuttings;
  q' = q rotatedabout(point 1/2 of q,90);
  (point 0 of q' { direction 0 of q' } 
  .. 
  { direction infinity of q  } point infinity of q { - direction infinity of q } 
  .. 
  { direction infinity of q' } point infinity of q'
  ) shifted e
enddef;

beginfig(1);
path ellipse; 
ellipse = fullcircle xscaled 2cm yscaled 4cm;
draw ellipse withcolor .63 red;
ahlength := 3;
filldraw arrowhead subpath (2,3) of ellipse;
draw open_arrowhead subpath (2,1) of ellipse;
draw curly_arrowhead subpath (1,2) of ellipse;
endfig;
end.

Notice that you need to draw my open-ended arrowheads, whereas the standard one needs filldraw. Note also how you can get reverse paths neatly with subpath.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .