答案1
看来您希望获得以下内容:
上图由正方形组成。一种方法是:
\documentclass[tikz, margin=3mm]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach \k in {0, 0.5, 1, 1.5}
{
\begin{scope}[shift={(\k cm,-\k cm)}]
\foreach \i in {0, 1,...,4}
{
\foreach \j in {0,1,...,4}
\node[draw, fill=white, minimum size=1 cm, outer sep=0pt]
at (\i, \j) {};
}
\end{scope}
}
\end{tikzpicture}
\end{document}
附录: 更简单的方法是用白色填充的矩形绘制网格:
\documentclass[tikz, margin=3mm]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach \i in {0, 0.5, ..., 1.5}
{
\draw[fill=white, xshift=\i cm, yshift=-\i cm] (0, 0) rectangle (4, 4);
\draw[xshift=\i cm, yshift=-\i cm] (0, 0) grid (4, 4);
}
\end{tikzpicture}
\end{document}
结果与以前相同