TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Cycle lets you close curves when drawing, and

\coordinate (a) at (0,0);
\coordinate (b) at (1,0);
\coordinate (c) at (0.5, -1);
\draw (a) -- (b) -- (c) -- cycle;

works fine. Shouldn't also

\node (a) at (0,0) {};
\node (b) at (1,0) {};
\node (c) at (0.5, -1) {};
\draw (a) -- (b) -- (c) -- cycle;

give the same result?

The former gives a triangle, while the second doesn't close up. Is this a bug or am I missing something regarding the cycle option?

(Of course, as a workaround I could use the coordinates to draw the cycled path, and then draw the nodes at the same coordinates, but still...)

share|improve this question
up vote 22 down vote accepted

When you specify a bare node as a coordinate, as in (a), then TikZ tries to be helpful and interpret that as the most appropriate target on a. Most of the time, this is exactly what you want: \tikz \draw[->] (0,0) node (a) {A} (1,0) node (b) {B} (a) -- (b); typesets A → B, with the arrow starting a little to the right of the A and ending a little to the left of the B.

However, when doing a "cycle", you don't want that behaviour. You want the lines to join up. Even empty nodes have size, unless you explicitly tell them not to. So you need to override this "helpfulness" which is done by specifying which target you mean. Thus:

\node (a) at (0,0) {};
\node (b) at (1,0) {};
\node (c) at (0.5, -1) {};
\draw (a.center) -- (b.center) -- (c.center) -- cycle;

does what you want it to.

There are other ways to do this, in particular as your nodes are empty you could force them to have zero size. Indeed, \coordinate is actually a shorthand for \node[coordinate] and the special shape coordinate has empty size. So your first example, which works, is actually a special case of the second where the nodes are fiddled to be "point masses".

share|improve this answer
Thanks! Great explanation. – gspr Oct 13 '10 at 11:23

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.