在 tikz 中完成循环

在 tikz 中完成循环

我正在尝试完成我的循环图,但我的最后一段 tikz 代码反转了箭头方向,导致图表无法完成。我知道只有最后一段弧线是错误的,但我不知道如何修复它。我遗漏了什么?

\documentclass[12pt]{article}
\usepackage[landscape,margin=1in]{geometry}
\usepackage{amsmath,tikz}

\begin{document}
\begin{center}
\begin{tikzpicture}
\def \margin {6}

\node[draw,circle] at (1*360/10:5cm) {9};
\node[draw,circle] at (2*360/10:5cm) {10};
\node[draw,circle] at (3*360/10:5cm) {7};
\node[draw,circle] at (4*360/10:5cm) {2};
\node[draw,circle] at (5*360/10:5cm) {8};
\node[draw,circle] at (6*360/10:5cm) {5};
\node[draw,circle] at (7*360/10:5cm) {4};
\node[draw,circle] at (8*360/10:5cm) {6};
\node[draw,circle] at (9*360/10:5cm) {1};
\node[draw,circle] at (10*360/10:5cm) {3};


\draw[->,>=latex] (1*360/10+\margin:5cm) arc (1*360/10+\margin:2*360/10-\margin:5cm);
\draw[->,>=latex] (2*360/10+\margin:5cm) arc (2*360/10+\margin:3*360/10-\margin:5cm);
\draw[->,>=latex] (3*360/10+\margin:5cm) arc (3*360/10+\margin:4*360/10-\margin:5cm);
\draw[->,>=latex] (4*360/10+\margin:5cm) arc (4*360/10+\margin:5*360/10-\margin:5cm);
\draw[->,>=latex] (5*360/10+\margin:5cm) arc (5*360/10+\margin:6*360/10-\margin:5cm);
\draw[->,>=latex] (6*360/10+\margin:5cm) arc (6*360/10+\margin:7*360/10-\margin:5cm);
\draw[->,>=latex] (7*360/10+\margin:5cm) arc (7*360/10+\margin:8*360/10-\margin:5cm);
\draw[->,>=latex] (8*360/10+\margin:5cm) arc (8*360/10+\margin:9*360/10-\margin:5cm);
\draw[->,>=latex] (9*360/10+\margin:5cm) arc (9*360/10+\margin:10*360/10-\margin:5cm);
\draw[->,>=latex] (10*360/10+\margin:5cm) arc (10*360/10+\margin:1*360/10-\margin:5cm);


\end{tikzpicture}
\end{center}

\end{document}

在此处输入图片描述

答案1

看看以下 MWE (最小工作示例) 是否对你有用:

\documentclass[12pt]{article}
\usepackage[landscape,margin=1in]{geometry}
\usepackage{tikz}

\begin{document}
    \begin{center}
\begin{tikzpicture}
    \def \margin {6}
\foreach \i [count=\j, count=\k from 2] in {9,10,7,2,8,5,4,6,1,3}
{
\node [draw,circle] at (\j*36:5cm) {\i};
\draw[-latex] (\j*36+\margin:5cm) arc (\j*36+\margin:\k*36-\margin:5cm);
}
\end{tikzpicture}
    \end{center}
\end{document}

在此处输入图片描述

答案2

好的,我明白了。最后一行代码应该是这样的:

\draw[->,>=latex] (10*360/10+\margin:5cm) arc (10*360/10+\margin:11*360/10-\margin:5cm);

相关内容