MWE (copied from TikZ manual):


    int \x;
    for \k in {0,10,...,350}{
      if \k>260 then { let \c = orange; } else {
        if \k>170 then { let \c = blue; } else {
          if \k>80 then { let \c = red; } else {
            let \c = green; }; }; };
        \path [fill=\c!50, draw=\c] (\k:0.5cm) -- (\k:1cm) --
        (\k+5:1cm) -- (\k+5:0.5cm) -- cycle;

This gives me the following error message:

! Undefined control sequence.
\tikz@math@if@@doifelse ...gfmathfloatparseactive 
                                                  \pgfmathfloattofixed {\pgf...
l.19   }

I have the same problem with other code that uses if in tikzmath and this also applies to TeX files that used to compile without problems some time ago. Is the current (MiKTeX) version of TikZ broken?

I'm using MikTeX 2.9 on Windows 10, packages have been updated a few minutes ago, just in case.

UPDATE: Just to make this clearer - even this simple tikzmath code gives the same error message.

  \x = 42;
  if \x == 42 then {
    {\fill (0,0) circle (1cm);};
  • Yes, there is something odd going on here. As far as I can see, \x, which was declared in int \x;, is not used here either. – user121799 Feb 21 at 19:31
  • The \x is not the problem. The error message occurs whenever if is used. See my update. – Frunobulax Feb 21 at 19:41
  • 1
    Yes. I did not claim the \x was the problem. This was just to substantiate something is odd here. – user121799 Feb 21 at 19:46

This is a bug in PGF/TikZ and should have been reported on the bugtracker. I did that for you and also fixed the bug. The workaround is also mentioned in the ticket https://sourceforge.net/p/pgf/bugs/517/

If you are not sure whether what you are observing is a bug or not, just try an example from the manual. If the example from the manual fails, it is definitely a bug.


Just add


to your preamble.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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