55

Unfortunately due to the way search engines work, this information isn't that easy to find.

Sometimes examples draw using --, sometimes -- +, sometimes -- ++.

I don't get the meaning!

For example, for this command:

\draw[fill=gray!50] (1,1) -- + (0:.5) arc (0:60:1) -- cycle;

What is the -- + there?

What does it mean if I change that to -- ?

bobobobo
  • 4,396

1 Answers1

63

The pluses modify the following coordinate making it relative to the previous saved coordinate. The difference between a single and a double plus is whether or not the saved coordinate is updated.

Thus:

\draw (1,1) -- ++(1,0) -- ++(0,1);

the second coordinate is actually (1,1) + (1,0) = (2,1) and the third is (2,1) + (0,1) = (2,2).

\draw (1,1) -- +(1,0) -- ++(0,1);

the second coordinate is actually (1,1) + (1,0) = (2,1) but the second coordinate is not saved so the third is relative to the first and thus is (1,1) + (0,1) = (1,2).

There's a slight change for bezier curves. If you do \draw (1,1) .. controls +(1,0) and +(0,1) .. ++(2,2) then the second control point is computed relative to the end point (which is very useful) and thus the controls are (1,1) + (1,0) for the first and (2,2) + (1,1) + (0,1) for the second (as the end point is itself relative to the initial position since the control points were specified with a single plus).

(Forgot to add the reference to the manual: to learn more, see Section 13.4 in the PGF manual (PGF2.10 version, might be a different section in other versions))

Andrew Stacey
  • 153,724
  • 43
  • 389
  • 751