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

I'm drawing nodes on a circle and switched from drawing lines based on coordinates to drawing them based on named nodes.

The problem now is, that with the following code the lines stop at the edges of the nodes, but don't point at the center.

How do I fix this?

    \draw (0,0) circle (6);

    \foreach \i in {0,...,\nodesminusone}
        \node[circle,fill=white,draw=black,thick] (node\i) at (-\i*\deltadegree+90:6) {\i};

    \foreach \i in {0,...,\nodesminusone}{
        \foreach \j in {0,...,\N}{
            \draw[->,thick,color=black!10] (node\i) -- (node\result);


    \foreach \i in {2} {
        % predecessor
        \draw (node\i) -- (node\result);

        % successor
        \draw (node\i) -- (node\result);

        % fingers
        \foreach \j in {0,...,\N}{
        \draw[->,color=blue,thick] (node\i) -- (node\result);
share|improve this question
up vote 7 down vote accepted

Replace \pgfmathsetmacro with \pgfmathtruncatemacro.

The reason why this happens is that \pgfmathsetmacro returns a floating (or fixed?) point number, not an integer. For example:

    \foreach \j in {0,...,\N}{
    \draw[->,color=blue,thick] (node\i) -- (node\result);

Here \result will be 0.0, 1.0, etc. (whatever the result of mod is). However (node1.0) means "Node 'node1' at angle 0degr", which draws the arrows to this point. With \pgfmathtruncatemacro the .0 will be truncated and only (node1) etc. is used which gives the wanted result.

share|improve this answer
perfect, thanks! This is hard to debug... any tipps on how I could have found this myself? – Zoran Zaric Feb 4 '11 at 23:55
The most difficult thing is to know where to start. But it is always good to look at your intermediate results. You could have looked at the definition of \result, i.e. using \show\result or better \edef\A{(node\i) -- (node\result)}\show\A to see what it passed to the \draw. – Martin Scharrer Feb 5 '11 at 0:07
Also, minimizing the document to two nodes plus one line might have shown the error more easily. Your code is already to big and complicated to post it like it is anyway. – Martin Scharrer Feb 5 '11 at 0:09
thanks a lot for the clarification – Zoran Zaric Feb 5 '11 at 0:12
@Zoran: You are welcome. Happy TeXing! – Martin Scharrer Feb 5 '11 at 0:22

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.