9

According to pgfmanual, i do think the following tex code should run. however, i failed to compile it with some error like the following picture. How to make it compiled.

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{calc,math}

\begin{document}

\begin{tikzpicture}
  \tikzmath{
    int \NROWS;
    int \NCOLS;

    int \NROWS1;
    int \NCOLS1;

    \NROWS = 9;
    \NCOLS = 9;

    \NROWS1 = \NROWS - 1;
    \NCOLS1 = \NCOLS - 1;
  }

  \foreach \Y in { 0,1,...,\NROWS1 }{
    \foreach \X in { 0,1,...,\NCOLS1 }{
      \draw (\X ,\Y) circle [radius=0.5cm];
    }
  }

\end{tikzpicture}


\end{document}

enter image description here

1 Answer 1

11

Like many TikZ commands like \draw, \fill , you can't have blank lines inside \tikzmath. To separate sections of code you could try inserting the comment character %:

\tikzmath{
    int \NROWS;
    int \NCOLS;
%
    int \NROWS1;
    int \NCOLS1;
%
    \NROWS = 9;
    \NCOLS = 9;
%
    \NROWS1 = \NROWS - 1;
    \NCOLS1 = \NCOLS - 1;
}

You must log in to answer this question.

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