答案1
例如,可以将网格的点设置为空圆节点。然后连接线将连接到圆,而圆的内部保持不变。可以通过嵌套\foreach
循环绘制二维网格:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \x in {0, ..., 5} {
\foreach \y in {0, ..., 3} {
\node[
circle,
minimum size=3pt,
draw,
inner sep=0pt,
] (n\x_\y) at (\x, \y) {};
}
}
\draw
(n0_0) -- (n1_0) -- (n2_0) -- (n3_0) -- (n4_0) -- (n5_0)
(n0_0) -- (n3_1)
(n1_0) -- (n3_1)
(n2_0) -- (n3_1)
(n3_0) -- (n3_1)
(n4_0) -- (n3_1)
(n4_0) -- (n4_1)
(n5_0) -- (n4_1)
(n5_0) -- (n5_1)
(n3_1) -- (n4_1) -- (n5_1)
;
\node[below] at (n0_0) {$(0, 0)$};
\node[above] at (n3_1) {$(a, 1)$};
\node[above right] at (n5_1) {$(a + b, 1)$};
\node[left=1ex] at (n0_3) {$v$};
\node[below=1ex] at (n5_0) {$t$};
\end{tikzpicture}
\end{document}
答案2
这是带有 的简短代码。如果设置了开关(MiKTeX) 或(TeX Live, MacTeX) pstricks
,则可以使用 进行编译:pdflatex
--enable-write18
-shell-escape
\documentclass[a4paper,11pt,x11names]{article}
\usepackage{pst-node, multido}
\usepackage{auto-pst-pdf}
\begin{document}%
\psset{xunit =1.5, nodesep=2pt, linecolor=IndianRed3}
\footnotesize
\begin{pspicture}
\multido{\Ix=0 + 1}{6}{\multido{\Iy=0 + 1}{4}{\dotnode(\Ix, \Iy){A\Ix\Iy}}}
\multido{\Ix=0 + 1}{5}{\ncline{A\Ix0}{A31}}
\multido{\I=0 + 1, \In=1 + 1}{5} {\ncline{A\I0}{A\In0}}
\ncline{A31}{A40}
\ncline{A41}{A31}\ncline{A41}{A51}\ncline{A41}{A40}\ncline{A41}{A50}\ncline{A50}{A51}
\uput[dl](A00){$ (0,0) $}\uput[dr](A50){$ t $}\uput[l](A03){$ V $}
\uput[ur](A31){$ (a, 1) $}\uput[ur](A51){$ (a + b, 1) $}
\end{pspicture}
\end{document}