这是我的示例代码:
\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}
但它会失败并\filldraw (0) circle (3pt);
出现错误消息“包 pgf 错误:不知道名为‘0’的形状。”
问:
当我按照所提到的答案操作时,是否会出现一些错误?
答案1
\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}