# PGF/TikZ: Relative coordinates behaving unexpected

In the below code, the second coordinate given with -- + seems to also update the path for further calculations. The shape I expected should look like a big Pi.

The PGF manual says about relative coordinates (page 133):

Instead of ++ you can also use a single +. This also specifies a relative coordinate, but it does not “update” the current point for subsequent usages of relative coordinates. Thus, you can use this notation to specify numerous points, all relative to the same “initial” point [...]

It works like I expect on the first point (to the left), but for the second it doesn´t. What did I oversee?

My output looks like this:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}

\draw (0,0) -- ++(0,3) -- +(-2.5,0) -- ++(3,0)  -- +(2.5,0) -- ++(0,-3);
\useasboundingbox(-3,-.5) rectangle (6,4);
\end{tikzpicture}
\end{document}

• That looks like what I'd expect. ++(0,3) shifts the reference point so +(-2.5,0) and ++(3,0) are measured relative to (0,3). Then the reference point is shifted to (3,3) and +(2.5,0) and ++(0,-3) are relative to that. – cfr Feb 8 '15 at 0:18
• @cfr please see the pic. I don´t get why the reference point for the last operation is (5.5,3) and not (3,3). – Paul Paulsen Feb 8 '15 at 0:24
• Okay, thanks for the answers, I got it. I mixed up "leaving reference point" and "leaving path position from which will be continued"... – Paul Paulsen Feb 8 '15 at 0:32
• Yeah, the reference point is (3,3). But I also thought the path had to start there, but it starts on (5.5,3)... – Paul Paulsen Feb 8 '15 at 0:41
• Oh, I see. Yes. The path is continuous unless, of course, you put a break in it. – cfr Feb 8 '15 at 0:43

I think it makes sense if you plot it out visually:

• The movement marked in red is relative to the point marked by the red circle.
• Likewise, the movements marked in blue are relative to the point marked by the blue circle.
• Finally, the movements marked in green are relative to the point marked by the green circle.

Code:

\documentclass[border=5pt,tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- ++(0,3) -- +(-2.5,0) -- ++(3,0)  -- +(2.5,0) -- ++(0,-3);
\begin{scope}[yshift=-40mm,red]
\draw [fill] (0,0) circle (1.5pt) node [right] {(0,0)} -- ++(0,3) node [below right] {3 up};
\end{scope}
\begin{scope}[yshift=-40mm,blue]
\draw [fill] (0,3) circle (1.5pt)  node [above] {(0,3)} -- +(-2.5,0) circle (1.5pt) node [below right, font=\small] {2.5 to the left} -- ++(3,0) node [below, font=\small] {3 to the right};
\end{scope}
\begin{scope}[yshift=-40mm,green]
\draw [fill] (3,3) circle (1.5pt)  node [above] {(3,3)} -- +(2.5,0) circle (1.5pt) node [above left, font=\small, xshift=5mm] {2.5 to the right} -- ++(0,-3) circle (1.5pt) node [left, font=\small] {3 down};
\end{scope}
\end{tikzpicture}
\end{document}


You have to use it like this:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}

\draw (0,0) -- ++(0,3) -- +(-2.5,0) -- ++(5.5,0)  -- ++(-2.5,0) -- +(0,-3);
\useasboundingbox(-3,-.5) rectangle (6,4);
\end{tikzpicture}
\end{document}


How?

1. Draw a line from (0,0) to (0,3) and change the origin by ++. New initial point is (0,3)
2. From (0,3) draw to -2.5 left
3. Draw from (-2.5,0) (with initial point as (0,3)) 5.5 to the right and update initial point to this point.
4. Now come back by 2.5 to the left (relative to (5.5,0) ).
5. From here draw down by 3 units.

A single + moves from the point by the amount given. For example

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


draws line from (1,1) to right by 2 units with respect to origin and 1 unit up with respect to origin. On the other hand

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


draws line from (1,1) to right by 2 units with respect to (1,1) and 1 unit up with respect to (1,1).

• Well, that one works, and I understand why. Honestly I can think of a couple of tricks to make this work. The thing I don´t understand is why my example doesn´t work... – Paul Paulsen Feb 8 '15 at 0:25
• Wait. Why does the first +(-2.5,0) update the initial point to (-2.5,3)? It has only one + so according to the manual it should leave the initial point untouched. – Paul Paulsen Feb 8 '15 at 0:27
• Okay, I got it. I thought that not only the reference point but also the path position from which is continued are left untouched by +, but that of course is wrong. Thanks for helping me to understand :) – Paul Paulsen Feb 8 '15 at 0:29