![如何用另一个网格覆盖一个网格](https://linux22.com/image/424862/%E5%A6%82%E4%BD%95%E7%94%A8%E5%8F%A6%E4%B8%80%E4%B8%AA%E7%BD%91%E6%A0%BC%E8%A6%86%E7%9B%96%E4%B8%80%E4%B8%AA%E7%BD%91%E6%A0%BC.png)
答案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}
结果与以前相同