我希望使用 Tikz 绘制一个图形,其形状最好描述为类似于卡通片中的杠铃。 一个最小的工作示例如下:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}[-,thick,scale=1]
\node (0) at (0,0) {0};
\node (1) at (-1,1) {1};
\node (2) at (-1,2) {2};
\node (3) at (0,3) {3};
\node (4) at (1,3) {4};
\node (5) at (2,2) {5};
\node (6) at (2,1) {6};
\node (7) at (1,0) {7};
\node (8) at (5,0) {8};
\node (9) at (4,1) {9};
\node (10) at (4,2) {10};
\node (11) at (5,3) {11};
\node (12) at (6,3) {12};
\node (13) at (7,2) {13};
\node (14) at (7,1) {14};
\node (15) at (6,0) {15};
\draw (0) to (1) to (2) to (3) to (4) to (5) to (6) to (7) to (0);
\draw (8) to (9) to (10) to (11) to (12) to (13) to (14) to (15) to (8);
\draw (5) to (10);
\draw (6) to (9);
\end{tikzpicture}
\end{center}
\end{document}
但是,我希望末端的节点圆圈能够类似于如下所示的效果:
\begin{center}
\begin{tikzpicture}[-,thick,scale=1]
\node (0) at (5*360/8 + 360/16: 1.6cm) {0};
\node (1) at (4*360/8 + 360/16: 1.6cm) {1};
\node (2) at (3*360/8 + 360/16: 1.6cm) {2};
\node (3) at (2*360/8 + 360/16: 1.6cm) {3};
\node (4) at (1*360/8 + 360/16: 1.6cm) {4};
\node (5) at (0*360/8 + 360/16: 1.6cm) {5};
\node (6) at (-1*360/8 + 360/16: 1.6cm) {6};
\node (7) at (-2*360/8 + 360/16: 1.6cm) {7};
\draw (0) to (1) to (2) to (3) to (4) to (5) to (6) to (7) to (0);
\end{tikzpicture}
\end{center}
但是,我不知道如何指定使用上述方法绘制的节点圆的中心,以及/或者如何使用此方法绘制两个彼此相邻的节点圆。
答案1
看看,这是否是你在寻找的:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}[-,thick,scale=1]
\node (10) at (5*360/8 + 360/16: 1.6cm) {0};
\node (11) at (4*360/8 + 360/16: 1.6cm) {1};
\node (12) at (3*360/8 + 360/16: 1.6cm) {2};
\node (13) at (2*360/8 + 360/16: 1.6cm) {3};
\node (14) at (1*360/8 + 360/16: 1.6cm) {4};
\node (15) at (0*360/8 + 360/16: 1.6cm) {5};
\node (16) at (-1*360/8 + 360/16: 1.6cm) {6};
\node (17) at (-2*360/8 + 360/16: 1.6cm) {7};
\draw (10) to (11) to (12) to (13) to (14) to (15) to (16) to (17) to (10);
\begin{scope}[xshift=50mm]
\node (20) at (5*360/8 + 360/16: 1.6cm) {0};
\node (21) at (4*360/8 + 360/16: 1.6cm) {1};
\node (22) at (3*360/8 + 360/16: 1.6cm) {2};
\node (23) at (2*360/8 + 360/16: 1.6cm) {3};
\node (24) at (1*360/8 + 360/16: 1.6cm) {4};
\node (25) at (0*360/8 + 360/16: 1.6cm) {5};
\node (26) at (-1*360/8 + 360/16: 1.6cm) {6};
\node (27) at (-2*360/8 + 360/16: 1.6cm) {7};
\draw (20) to (21) to (22) to (23) to (24) to (25) to (26) to (27) to (20);
\end{scope}
\draw (15) to (22) (16) to (21);
\end{tikzpicture}
\end{center}
\end{document}