4

MWE (copied from TikZ manual):

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{math}

\begin{document}
\begin{tikzpicture}
  \tikzmath{
    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;
      };
    };
  }
\end{tikzpicture}
\end{document}

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.

\tikzmath{
  \x = 42;
  if \x == 42 then {
    {\fill (0,0) circle (1cm);};
  };
}
3
  • 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
    Commented Feb 21, 2019 at 19:31
  • The \x is not the problem. The error message occurs whenever if is used. See my update.
    – Frunobulax
    Commented Feb 21, 2019 at 19:41
  • 1
    Yes. I did not claim the \x was the problem. This was just to substantiate something is odd here.
    – user121799
    Commented Feb 21, 2019 at 19:46

1 Answer 1

6

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.

Workaround

Just add

\usetikzlibrary{fpu}

to your preamble.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .