In TikZ, is it possible to clip away a line? I would like to create a thin layer around an arrow in which nothing should be drawn (i.e. keep what is there at the moment the arrow is drawn) to create the feeling that the arrow lies above all shapes that are drawn there afterwards. I have figured that I want to clip away a region that looks like the arrow but is just a bit thicker in order to get the effect that I want. How can I achieve that?

  • I don't think this will work, since only the centerline of a thick line is used for determining the clipping boundary. – Jake Aug 2 '13 at 4:39

Try something like this:

\tikzset{invclip/.style={clip,insert path={{[reset cm]
      (-16383.99999pt,-16383.99999pt) rectangle (16383.99999pt,16383.99999pt)

\coordinate(A) at (0,0);

\draw[->,line width=2pt](A)-+(50:3)coordinate(B);


I've used the negative clipping from here: How can I invert a 'clip' selection within TikZ?

What you need to do:

Define a macro which automates this part:

\draw[->,line width=2pt](A)-+(50:3)coordinate(B);

Exact implementation depends on the way you define your coordinates.

Here's a (not very sophisticated) example:

\draw[->,line width=#4](#1)-+(#2:#3)coordinate(B);

The first argument is the starting point of the vector, the second the direction (in degree), 3rd argument ist the length and the 4th is the line width.


[Also currently the clipping is a little broken (it clips away everything which isn't in the 1st quadrant - that can be fixed i guess but currently i haven't got the time to do it myself.] Ignore this - i think i've fixed it (by copying the other answer in the previously linked question).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.