Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

PGF 2.0 Manual says,

You can add a single + sign in front of a coordinate or two of them as in +(1cm,0cm) or ++(0cm,2cm). Such coordinates are interpreted differently: The first form means,"1cm upwards from the previous specified position" and the second means, "2cm to the right of the previous specified position, making this the new specified position."

They provide this as an example:

\begin{tikzpicture}[scale=3]
\clip (-0.1,-0.2) rectangle (1.1,0.75);
\draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
\draw (-1.5,0) -- (1.5,0);
\draw (0,-1.5) -- (0,1.5);
\draw (0,0) circle (1cm);
\filldraw[fill=green!20,draw=green!50!black]
(0,0) -- (3mm,0mm) arc (0:30:3mm) -- cycle;
\draw[red,very thick] (30:1cm) -- +(0,-0.5);
\end{tikzpicture}

Now, if I change +(0,-0.5) to ++(0,-0.5), all remains same! Shouldn't the later be 0.5 left to the previously specified coordinate, i.e., (30:1cm) ?

share|improve this question

2 Answers 2

up vote 10 down vote accepted

The difference will be clear if you make a new point relative to the last point. An example:

\begin{tikzpicture}
\draw (0,0) -- +(1,1) -- +(2,0);
\fill [red] (0,0) circle (3pt);
\end{tikzpicture}
\begin{tikzpicture}
\draw (0,0) -- ++(1,1) -- +(2,0);
\fill [red] (0,0) circle (3pt);
\end{tikzpicture}

In the first picture, the last coordinate is 2 cm to the right of the first coordinate, while in the second picture, the last coordinate is 2 cm to the right of the second coordinate, because, this is the "new specified position".

share|improve this answer
    
I see, thanks a lot. So '+' is used as an offset to the current position right? Like, go x and y steps from current specified position?? –  user1553 Dec 23 '10 at 13:58

Perhaps a shorter example could suffice:

  \draw (0,0) -- +(2,0) -- ++(0,1) -- +(2,0);
  % the first line (-- +(2,0) ) draws a line to 2cm to the right, *relative* to
  % the point of origin (0,0) *without* updating where we are then situated in
  % the current path.
  % the second line (-- ++(0,1) ) on the other hand, *does* update the location
  % where we are situated on the current path.

The result resembles mirrored letter "Z"

share|improve this answer
    
+1 for mentioning relative –  user1553 Dec 23 '10 at 14:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.