下面的代码归功于 Jerome Tremblay,原始代码可以在这里找到这里
% A simple cycle
% Author : Jerome Tremblay
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\def \n {5}
\def \radius {3cm}
\def \margin {8} % margin in angles, depends on the radius
\foreach \s in {1,...,\n}
{
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$\s$};
\draw[->, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
}
\end{tikzpicture}
\end{document}
一切都运行正常,直到我想使用其他节点,例如来自此列表的节点
{a,b,c,d,e,f,g,h,i}
应该是排版的,而不是按数字排序的节点。你能帮忙吗?
答案1
好,我知道了。
\begin{tikzpicture}
\def \n {9}
\def \radius {3cm}
\def \margin {8} % margin in angles, depends on the radius
\foreach \s in {1,...,\n}
{
\draw[->, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
}
\foreach \t [count=\i] in {a,b,c,d,e,f,g,h,i}
{
\node[draw, circle] at ({360/\n * (\i - 1)}:\radius) {\t};
}
\end{tikzpicture}