0

This may be one duplicate of this QA. But I failed to use its answer.

Here is my example code:

\documentclass{article}
\usepackage{tikz}
\usepackage{fp}

\newcommand{\xMin}{0}% \newcommand{\xMax}{4}% \newcommand{\yMin}{0}% \newcommand{\yMax}{3}% \begin{document} \begin{tikzpicture}

\foreach \i in {\xMin,...,\numexpr\xMax-1\relax} { \foreach \j[evaluate={\index=\i+4*\j}] in {\yMin,...,\numexpr\yMax-1\relax} { \FPadd\xcoord{\i}{0.5} \FPadd\ycoord{\j}{0.5} \node (\index) at (\xcoord,\ycoord) {a}; } } \filldraw (0) circle (3pt); \end{tikzpicture}

\end{document}

But it will fail at \filldraw (0) circle (3pt); with the error message "Package pgf Error: No shape named `0' is known."

Q:

Are there some errors when I follow the answer referred to?

An5Drama
  • 63
  • 6

1 Answers1

3
\documentclass[tikz, border=1 cm]{standalone}
\usepackage{fp}
\newcommand*{\xMin}{0}
\newcommand*{\xMax}{4}
\newcommand*{\yMin}{0}
\newcommand*{\yMax}{3}
\begin{document}
\begin{tikzpicture}
\foreach \i in {\xMin,...,\numexpr\xMax-1\relax} {
\foreach \j[evaluate={\index=int(\i+4*\j)}] in {\yMin,...,\numexpr\yMax-1\relax} {
\FPadd\xcoord{\i}{0.5}
\FPadd\ycoord{\j}{0.5}
\node (\index) at (\xcoord,\ycoord) {\index}; %changed to show \index
}}
\filldraw (0) circle (3pt);
\end{tikzpicture}
\end{document}

4x3 grid with numbers and a circle