# How can you update the current relative coordinate in TikZ without adding an element?

Is it possible to update the current relative coordinate in TikZ without actually adding anything to the picture? For instance,

\node at ++(1, 0) (node1) {...};


will update the current x coordinate by incrementing it by 1, but how can I do this without actually adding a node? Also, it is possible to increment the position within a loop (i.e. to keep the new value between the iterations)?

-
you can use coordinate if you like. I don't know exactly why you don't want nodes so maybe it is also not good with coordinates. Regarding the iteration question, you can use \foreach \x [remember=\x as \lastx (initially x0)] in {x1,x2...,xn}{......}. I hope I understood your question correctly. – percusse Sep 26 '11 at 12:24
You can also use the grid path to avoid using a \foreach loop. The x and y steps can be set independently. It would be helpful though, if you gave some information on what exactly you need to increment the coordinate. – Count Zero Sep 26 '11 at 12:53
I think we need a little more detail here as to what you are trying to do. For example, \path (1,0) ++(2,0) ++(3,0) node {a node}; will work, but may be your actual case is more complicated. – Loop Space Sep 26 '11 at 13:34
If you just want to increment the current coordinate, you could try \path ++(1,0);. – Ryan Reich Sep 26 '11 at 15:46

As mentioned by others in the comments, you an use \path to update the current relative position. ++(…) is relative to the last saved position within a particular path, but the start of a path is relative to (0,0). Consider the following example:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node at (0,0) {O};% label the origin
\node at ++(1, 0) [orange] {A};% this is relative to (0,0)
\node at ++(2, 0) [green] {B};% still relative to (0,0)
\path ++(2, 0) ++ (1,0) node [blue] {C};% start relative to (0,0), go to (2,0) and then relative to this end up at (3,0)
\path ++(5,0) ++ (1,0) node [red] {D};
\end{tikzpicture}
\end{document}


The lines starting with \node at ++(1, 0) and \node at ++(2, 0), are both relative to (0,0). The subsequent lines starting with \path ++(2, 0) ... starts the path relative to (0,0), and moves to (2,0), and the subsequent ++ (1,0) is relative to the last point and hence the C is placed at (3,0). Note that that nothing was placed at (2,0) during this path.

Just to be sure, the last \path sets the current coordinate to (5,0) and nothing is added to the picture there, only at (6,0) do we see D.

-