[Tex/LaTex] Can anyone please explain + vs ++ operator in PGF

tikz-pgf

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) ?

Best Answer

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".

Related Question