我想将此图像转换为 Ti钾Z。
我已经有以下代码,但我不知道如何将数字放在顶点以及如何将红色条放在 2 和 3 之间。有人可以解释一下如何做到这一点吗?
\documentclass{article}
\usepackage{xcolor}
\definecolor{navyblue}{rgb}{0.0, 0.0, 0.5}
\usepackage{
pst-poly,
pstricks-add
}
\usepackage[
% locale = DE,
round-mode = places,
round-precision = 2
]{siunitx}
\ExplSyntaxOn
\cs_new_eq:NN
\calc
\fp_eval:n
\ExplSyntaxOff
% calculations
\newcommand*\Angle{\calc{360/\sides}}
\newcommand*\sidelength{\calc{2*\radius*sin(pi/\sides)}}
\newcommand*\radiusI{\calc{\radius*cos(pi/\sides)}}
\newcommand*\areaI{\calc{pi*\radiusI^2}}% not used
\newcommand*\areaC{\calc{pi*\radius^2}}% not used
\newcommand*\areaRatio{\calc{cos(pi/\sides)^2}}% not used
\psset{dimen = middel}
\begin{document}
% constants
\newcommand*\sides{5}
\newcommand*\radius{3.5}
\begin{center}
\begin{pspicture}(-\radius,-\radius)(\radius,\radius)
% centre
\pnode(0,0){C}
% regular polygon with dots at corners
\rput(C){%
\PstPolygon[
PolyNbSides = \sides,
unit = \radius,
PolyRotation=18,
linecolor = navyblue
]
}
{\psset{linecolor = gray}
% circumscribed circle
\pscircle(C){\radius}}
\end{pspicture}
\end{center}
\bigskip
\end{document}
答案1
带有 的简短代码pst-poly
。我不得不引入一个新的“ vertex
”计数器,因为该选项PolyName=…
允许对顶点进行编号,但它们的顺序不是 OP 所要求的顺序:
\documentclass[svgnames]{article}
\usepackage{pst-poly}
\usepackage{auto-pst-pdf}
\usepackage{etoolbox}
\colorlet{PolygonColor}{Thistle}
\colorlet{PolygonColor1}{red}
\colorlet{VertexColor}{NavyBlue}
\colorlet{LabelColor}{OrangeRed!80!}
\begin{document}
\psset{unit=3.5cm, dimen=middle, linejoin=1, dotsize=3.5pt, arrowinset=0.15, shortput=nab}
\begin{pspicture}(-1,-1)(1,1)
% centre
\pnode(0,0){C}
% circumscribed circle
\pscircle[linecolor =LightSlateGray!60](C){1}
% regular polygon with dots at corners
\psset{linecolor=PolygonColor}
\newcounter{vertex}
\setcounter{vertex}{4}
\providecommand{\PstPolygonNode}{\rput * { * 0}(1.09;\INode){\addtocounter{vertex}{-1}\ifnumequal{\value{vertex}}{0}{\setcounter{vertex}{5}}{}\color{LabelColor}\thevertex}\psdots[linecolor =VertexColor](1;\INode)}
\rput(0,0){\PstPentagon[PolyName=A, linecolor=white] }
\psset{arrows=<-, arrowsize =2.5pt 2, nodesepA=1.7pt, nodesepB =1.75pt, linecolor=PolygonColor, linewidth=1.2pt}
\ncline{A1}{A2}\ncline{A2}{A3}_{$\tau$}\ncline{A3}{A4}\ncline{A4}{A5}\ncline{A5}{A1}
\ncline[offset=4pt, linecolor=PolygonColor1, arrows=<->]{A1}{A2}^{$ \sigma$}
\end{pspicture}
\end{document}
答案2
这是一个 TikZ 解决方案。它使用foreach
循环来绘制边缘。循环 ( ) 的值{2,1,a5,B,$\alpha$}
用作标签,从顶部开始然后顺时针方向。此外,count=\c
跟踪当前角,并在每个角中创建坐标(称为c1
,c2
依此类推),以便您之后可以轻松访问它们。markings
装饰用于沿多边形放置箭头尖,因为有五个,每条边代表整个路径的 20%(或 0.2)。由于舍入不准确,箭头的位置可能不好(例如,如果半径\r
等于 1),为了解决这个问题,可以将尖端更多地放在边缘上(容易)或更改为另一个箭头放置设施(稍微不那么容易)。
代码
\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\r}{3}
\draw circle (\r);
\draw[decoration={markings, mark=between positions 0.2 and 1 step 0.1999 with \arrow{latex}}, postaction=decorate] (162:\r)
\foreach \l [count=\c] in {2,1,a5,B,$\alpha$}
{ -- (162-\c*72:\r) coordinate (c\c) node at (162-\c*72:\r+0.3) {\l}
};
\draw[red, thick, -latex] (c3) -- (c5);
\end{tikzpicture}
\end{document}
输出
答案3
使用 tikz
\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz}
\definecolor{navyblue}{rgb}{0.0, 0.0, 0.5}
% calculations
\newcommand*\Angle{\calc{360/\sides}}
\begin{document}
% constants
\newcommand*\sides{5}
\newcommand*\radius{3.5}
\begin{center}
\begin{tikzpicture}[>=stealth]
\draw[gray,thick](0,0)circle(\radius);
\foreach \i in {1,...,5}{\node[fill,circle,inner sep=2pt,label=90-(\i-2)*\Angle:$\i$](\i) at ({90-(\i-2)*\Angle}:\radius){};}
\foreach \i/\j in {1/2,2/3,3/4,4/5,5/1}{
\draw[thick,navyblue,->](\i)--(\j);}
\draw[red,<->](2)--(3)node[midway,below]{r};
\end{tikzpicture}
\end{center}
\end{document}
更新
要改变顶点的数字,您可以\foreach
像这样修改里面的变量\foreach \i/\j in {1/2,2/4,3/5,4/1,5/3}{\node[fill,circle,inner sep=2pt,label=90-(\i-2)*\Angle:$\j$](\i) at ({90-(\i-2)*\Angle}:\radius){};}
以获得按以下顺序排列的数字:2,4,5,1,3。