# [pstricks] Is it possible to pass an expression to \multido's repetitions argument?

Alexander Grahn A.Grahn at hzdr.de
Fri Nov 23 10:05:11 CET 2012

On Thu, Nov 22, 2012 at 07:20:01PM +0000, Sky Hester (No Email) wrote:
>I am attempting to create an animation with \animateinline using a command that involves \multido. When I compile the following, I receive the error
>
>"! Missing number, treated as zero.
>                   !
>l.44 	}"
>
>Which I assume means I can't put postscript expressions where I'm trying to use them.
Right, the second argument of \multido needs to be known at LaTeX
run-time, but Postscript expressions are evaluated only at the PS to PDF
conversion step, which is too late.

In the example below, the floating point unit of LaTeX3 is used to do
the calculation.

Next, you should use \multiframe macro instead of \whiledo with embedded
\newframe.

\documentclass[12pt]{report}
\usepackage[margin=1in]{geometry}

\usepackage{pstricks}
\usepackage{auto-pst-pdf}
\usepackage{ifthen}
\usepackage{animate}
\usepackage{expl3} % LaTeX3 interface

\ExplSyntaxOn
\def\calculate#1#2{%
\fp_to_int:n{round0(#1/2,0)+#2}
}
\ExplSyntaxOff

%Command to draw diagrams
\newcommand{\cycle}[2]{% #1: n, #2: k, number of edges plotted
\begin{pspicture}(-3,-2)(3,2)
\SpecialCoor
\pscircle[linewidth=0.01](0,0){2}
\degrees[#1]
%All edges up to k,
\multido{\ii=0+1}{#2}{%
\multido{\ij=0+1}{\calculate{#1}{\ii}}{%
\psline[linestyle=dashed,linewidth=0.01]%
(2;\ii)(2;\ij)
}%
}
\multido{\i=0+1}{#1}{%
\psdots[dotscale=1]%
(2;\i)
}
\end{pspicture}%
}

\begin{document}

\begin{center}
\begin{animateinline}[step,palindrome]{1}%
\multiframe{13}{iStep=0+1}{%
\cycle{12}{\iStep}%
}%
\end{animateinline}%
\end{center}

\end{document}