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 have the following problem: I want to draw some moiree effects in tikz. This seems to be no problem. I did it without any error (two circles of trapezia). Now the two rings should be moved a bit. I added things and nothing worked anymore. I give you a reduced code below. Unfortunately the problem arises only if I calculate the movement by pgfmath. If I give them directly, all right, no error.

The (reduced) code:

    \foreach \i 
        evaluate=\i as \startAngle using 360/#1*(\i-1)+#2,
        evaluate=\i as \endAngle using 360/(2*#1)*(2*\i-1)+#2
    in {1,...,#1}
        \draw (\startAngle:2cm) -- (\startAngle:3cm) -- (\endAngle:3cm) -- (\endAngle:2cm) -- cycle;

        { [color=red]
        { [color=blue]
    \caption{Moiree Test mit #2 und #3 Strichen (Delta #1).}




If you replace the \pgfmathresult by 0 or delete the optional argument you see the correct 3 trapezia in blue.

Can you tell me, where is my fault? Thanks

share|improve this question
up vote 5 down vote accepted

\pgfmathresult is a temporary register and it's being used very frequently by TikZ itself. So before you use it in your custom macro, it has been overwritten many times by TikZ. You can either expand the value of the \pgfmathresult by


when you are calling it such that it's current value is passed or you can set the result to some other macro that is not disturbed by other things e.g.

share|improve this answer

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.