答案1
先画网格:
\begin{tikzpicture}[scale=0.5]
\draw (0,0) grid (6,6);
\foreach \x in {0,1,2,3,...,6}{
\node[black, fill=white, below] at (\x,3){\x};
}
\end{tikzpicture}
答案2
您正在绘制一个节点(带有白色背景),然后绘制网格,然后绘制其他节点,再次绘制网格,...这是因为您将网格里面。\foreach
如果你把网格放在前面,\foreach
你就拥有了它。
\documentclass[tikz,border=2mm] {standalone}
\begin{document}
\begin{tikzpicture}[scale=0.5]
\draw (0,0) grid (6,6); % outside the \foreach, we want to draw just one grid
\foreach \x in {0,...,6}
\node[black, fill=white, below] at (\x,3){\x};
\end{tikzpicture}
\end{document}