我是 TikZ 新手,正在尝试绘制一个大网格。想通过用省略号 (ldots/vdots) 替换行/列来强调它是一个大网格;就像在大型矩阵中所做的那样。还没有取得很大进展;任何帮助都值得感激!
答案1
我提供两种方案。两种方案的思路是一样的:借助命令来减少代码\foreach
。
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line join=round,line join=cap]
% BLACK GRID
\foreach\i in {0,90,180,270}
{%
\begin{scope}[rotate=\i,transform shape]
\draw[step=0.5cm] (0.5,0.5) grid (3,3);
\foreach\j in {0.75,1.25,...,2.75}
\node at (0,\j) {$\cdots$};
\end{scope}
}
\node at (0,0.1) {$\ddots$}; % vertical align "by hand"
% BLUE GRID
\begin{scope}[shift={(7,0)},blue]
\foreach\i in {0,90,180,270}
{%
\begin{scope}[rotate=\i]
\draw[step=0.5cm] (0.4,0.4) grid (3,3);
\foreach\j in {0.5,1,...,3}
\draw[dotted] (-0.3,\j) -- (0.3,\j);
\end{scope}
}
\end{scope}
\end{tikzpicture}
\end{document}
答案2
我自己想出了这个,所以
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[every node/.style={minimum size=.5cm-\pgflinewidth, outer sep=0pt}]
\draw[step=0.5cm,color=black] (0,0) grid (2.5,2.5);
\node at (3,1.75) {\ldots};
\node at (3,1.25) {\ldots};
\node at (3,0.75) {\ldots};
\node at (3,0.25) {\ldots};
\node at (3,2.25) {\ldots};
\draw[step=0.5cm,color=black] (3.4999,0) grid (6,2.5);
\node at (0.25,3) {\vdots};
\node at (0.75,3) {\vdots};
\node at (1.25,3) {\vdots};
\node at (1.75,3) {\vdots};
\node at (2.25,3) {\vdots};
\draw[step=0.5cm,color=black] (0,3.499) grid (2.5,6);
\node at (3.75,3) {\vdots};
\node at (4.75,3) {\vdots};
\node at (4.25,3) {\vdots};
\node at (5.25,3) {\vdots};
\node at (5.75,3) {\vdots};
\draw[step=0.5cm,color=black] (3.499,3.499) grid (6,6);
\node at (3,3.75) {\ldots};
\node at (3,4.25) {\ldots};
\node at (3,4.75) {\ldots};
\node at (3,5.25) {\ldots};
\node at (3,5.75) {\ldots};
\end{tikzpicture}
\end{document}