答案1
一种可能性是做一个宏来绘制集合(圆)和点,并为每个点命名。然后你所要做的就是连接所需的点。它可能像这样:
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
% Macro
\def\r{2} % raduis
\newcommand{\myset}[4] % name, position x, position y, number of points
{%
\begin{scope}[shift={(#2,#3)}]
\coordinate (#1) at (0,0) {};
\draw (0,0) circle (\r);
\pgfmathsetmacro\angle{360/#4}
\foreach\i in {1,...,#4}
{%
\pgfmathsetmacro\thisangle{-\angle*(\i-1)+90-0.5*\angle}
\coordinate (#1-\i) at (\thisangle:\r);
\node at (\thisangle:1.1*\r) {$\i$};
\fill (\thisangle:\r) circle (1pt);
}
\end{scope}
}
\begin{document}
\begin{tikzpicture}[line join=round, line cap=round]
% A set with 8 points
\myset{S1}{0}{0}{8}
\draw (S1-1) -- (S1-3) -- (S1-8) -- cycle;
\draw (S1-5) -- (S1-7);
% Anotehr set with 10 points
\myset{S2}{5}{0}{10}
\draw (S2-2) -- (S2-5) -- (S2-7) -- (S2-9) -- cycle;
\draw (S2-6) -- (S2-8);
\end{tikzpicture}
\end{document}
答案2
我提出了基于 pst-poly
pstricks 包的这个简短代码:
\documentclass[x11names, border = 3pt]{standalone}%
\usepackage{fourier}
\usepackage{pst-poly}
\usepackage{multido}
\begin{document}
\begin{pspicture}(-2,-2)(2,2)%
\psset{unit = 1.25}
\pscircle(0,0){1}
\providecommand{\PstPolygonNode}{%
\psdots[dotstyle=o, dotsize=2pt,fillstyle = solid, fillcolor=IndianRed3](1;\INode)}
\psset{ linewidth = 0.6pt}
\rput(0,0){\PstOctogon[linestyle = none, PolyName=A, PolyRotation=45]}
\psset{nodesep=1pt, linecolor=LightSteelBlue3}
\ncline{A2}{A3}\ncline{A3}{A8}\ncline{A8}{A2}
\ncline{A4}{A6}
\psset{labelsep=3pt}
\multido{\i=3+1,\Id=8 + -1, \na=112.5+45}{6}{\nput{\na}{A\i}{\scriptsize\Id}}
\nput{22.5}{A1}{\scriptsize2}\nput{67.5}{A2}{\scriptsize1}
\end{pspicture}
\end{document}