错误“缺少 = 插入 \ifnum”

错误“缺少 = 插入 \ifnum”

我正在尝试使用 \ifnum 来创建一个图形,但我一次又一次地收到该错误,不知道为什么,有人可以帮忙吗?这是我的代码:

    \begin{figure}[H]
\begin{center}
\begin{tikzpicture}

\def \n {24}
\def \radius {6.5cm}
\def \nradius {0.2cm}
\def \margin {2} % margin in angles, depends on the radius
\definecolor{mycolor}{RGB}{254,199,184}
\foreach \s in {1,...,\n}
{
  \node (\s) [circle, fill=mycolor, minimum width=\nradius] at ({360/\n * (\s - 1)+90}:\radius) {};
  \node [fill=none, minimum width=\nradius] at ({360/\n * (\s - 1)+90}:\radius) {\footnotesize \s};
}

\foreach \s in {1,...,\n}
{
    \pgfmathparse{\s+1} \let\ss\pgfmathresult 
    \pgfmathparse{\s+3} \let\sss\pgfmathresult  
    \foreach \k in {\ss,\sss,...,\n}{
            \ifnum\k<25
            \draw[->, >=latex, thick] (\s) -- (\k);
        \fi      
    }
}
\end{tikzpicture}
\caption{\label{oclique24} Oriented version of the title page absolute o-clique}
\end{center}
\end{figure}

答案1

\pgfmathresult2.0第一个循环返回,其他循环类似,不是整数。使用\pgfmathtruncatemacro

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\def \n {24}
\def \radius {6.5cm}
\def \nradius {0.2cm}
\def \margin {2} % margin in angles, depends on the radius
\definecolor{mycolor}{RGB}{254,199,184}
\foreach \s in {1,...,\n}
{
  \node (\s) [circle, fill=mycolor, minimum width=\nradius] at ({360/\n * (\s - 1)+90}:\radius) {};
  \node [fill=none, minimum width=\nradius] at ({360/\n * (\s - 1)+90}:\radius) {\footnotesize \s};
}

\foreach \s in {1,...,\n}
{
    \pgfmathtruncatemacro{\ss}{\s+1}
    \pgfmathtruncatemacro{\sss}{\s+3}
    \foreach \k in {\ss,\sss,...,\n} {
       \ifnum\k<25
            \draw[->, >=latex, thick] (\s) -- (\k);
       \fi      
    }
}
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容