如何在 Latex 中创建带有标签的圆形图?

如何在 Latex 中创建带有标签的圆形图?

我正在尝试在 Latex 中用标签绘制这些图表。 无代码的图表

我已经用以下代码绘制了这种风格的图表:

\documentclass[tikz, border=5]{standalone}
\usetikzlibrary{calc,arrows}
\tikzset{
every node/.append style={circle, minimum size=4pt,fill},
every label/.append style={rectangle},
>=latex}

\begin{document}

\begin{tikzpicture}

\node (1) [label=left:1] {};
\node (7) [label=left:7, above right of=1] {};
\node (8) [label=right:8, right of=7] {};
\node (2) [label=right:2, below right of=8] {};
\node (5) [label=left:5, above of=7] {};
\node (6) [label=right:6, right of=5] {};
\node (3) [label=left:3, above left of=5] {};
\node (4) [label=right:4, above right of=6]{};

\draw (1) -- (2) -- (4) -- (3) -- (1) --(7) -- (2) -- (8) -- (6) -- (3) -- (5) -- (7) -- (8);
\draw (4) -- (6) -- (5);
\end{tikzpicture}

\end{document}

带标签的图表

答案1

所有 4 个图表只需要几行代码即可完成。如果您使用文档类的选项,pst-poly可以使用 pdflatex 进行编译,前提是您使用开关 (MiKTeX) 或(TeXLive、MacTeX) 进行编译:pdf--enable-write18-shell-escape

\documentclass[pdf, x11names]{article}
\usepackage[utf8]{inputenc} 
\usepackage{fourier} 

\usepackage{pst-poly}

\begin{document}
\psset{unit=2cm, dotstyle=o, dotsize=6pt, fillcolor=cyan, linewidth=0.6pt, nodesep=3pt}

\begin{pspicture*}(-1.25,-1)(1.25,1.1)
\providecommand{\PstPolygonNode}{%
\psdots(1;\INode)}
 \rput(0,0){\PstSquare[PolyName =A, unit = 2cm]}
 \uput[r](A1){4} \uput[l](A2){3} \uput[l](A3){1}\uput[r](A4){2}
 \rput(0,0){\PstSquare[PolyName =B, unit = 1cm]}%
 \uput[r](B1){6} \uput[l](B2){5} \uput[l](B3){7}\uput[r](B4){8}
 \ncline{A2}{B1} 
 \multido{\i = 1 + 1}{4}{\ncline{A\i}{B\i}}
\end{pspicture*}
\hskip2cm
\begin{pspicture*}(-1.25,-1)(1.25,1.1)
\providecommand{\PstPolygonNode}{%
\psdots(1;\INode)}
 \rput(0,0){\PstPentagon[PolyName=P, unit=1.6cm]}
 \rput(0,0){\PstPentagon[PolyName=Q, PolyOffset = 2,unit = 0.8cm]}%
 \multido{\i = 1 + 1}{5}{\ncline{P\i}{Q\i}}
\end{pspicture*}
\vskip1cm

\begin{pspicture*}(-1.25,-1)(1.25,1.1)
\providecommand{\PstPolygonNode}{%
\psdots(1;\INode)(0,0)}
 \rput(0,0){\PstHexagon[PolyName=H, unit=1.6cm]}
 \rput(0,0){\PstPolygon[PolyRotation=30,PolyNbSides=3, PolyName=T, unit=0.8cm, linestyle=none]}%
 \multido{\i = 1 + 1}{3}{\ncline{T0}{T\i}}
 \ncline{H3}{T1}\ncline{H2}{T2}
 \ncline{H1}{T3}\ncline{H4}{T3}
 \ncline{H5}{T2}\ncline{H6}{T1}
\end{pspicture*}
\hskip 2cm
\begin{pspicture*}(-1.25,-1)(1.25,1.1)
\providecommand{\PstPolygonNode}{%
\psdots(1;\INode)(0,0)}
 \rput(0,0){\PstNonagon[PolyName=N, unit=1.6cm]}
 \multido{\i = 2 + 3}{3}{\ncline{N0}{N\i}}
\ncline{N1}{N6}%
\ncline{N3}{N7}%
\ncline{N4}{N9}%
\end{pspicture*}

\end{document} 

在此处输入图片描述

相关内容