2

I'm trying to use \ifnum to create a figure but i'm getting that error again an again without knowing why, can anyone help on this. Here is my code :

    \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}
0

1 Answer 1

2

\pgfmathresult returns 2.0 for the first cycle and similarly for the others, not integers. Use \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}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .