Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I tried the Asymptote pdfmovie.asy example and the frames came up in the wrong order. I tried numerous other examples, including wheel.asy, and several of my own tests always with the same results. Basically, the frame order is always:

45 frames, 1 to 45: 1, 2, 13, 24, 35, 41 .. 45, 3 .. 12, 14 .. 23, 25 .. 34, 36..40.

This varies with the number of frames, but there is a pattern (shown below). Sample asymptote code to generate x number of frames (up to 45 but easily extended to as large as you want to test):

// Test Media9 Animate.

// Uncomment the following 2 lines to support pdf animations:

import graph;
import animation;


// Draw axes.
xaxis( L="x", xmin = -1.0, xmax = 1.0, arrow=EndArrow(3));
yaxis( L="y", ymin = -0.2, ymax = 1.2, arrow=EndArrow(3));

// new array
int [] arrayr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};//, 32, 33, 34, 35, 36, 37, 38, 39,
//40, 41, 42, 43, 44, 45};

animation a;

// Process all radius entries
for(int j=0; j < arrayr.length; ++j)
  label(format("\small r= %d",arrayr[j]),(-.45,.45));  // So I know the frame number.
  a.add(); // Add current picture to animation.


// Merge the images into a pdf animation.

At first I thought it was this code. Then I thought it was animation.asy. But, by saving the pdf files, I'm able to generate the same results with this LaTeX file:

% Try to make Figure 4.




The pdf files here have the name _fig4+00.pdf through _fig4+26.pdf. I had added the leading zero to see if that was what was causing the problem but it wasn't; this doesn't fix it.

So then I modified Asymptote's animation.asy program to call animate graphics with a timeline file, and built a timeline file to specify the order of the frames. The timeline file for these 27 images looks like:


And in the tex file above, changed the line to:


and this works correctly.

So I can work around the problem by changing Asymptote's animation.asy file:

// animation delay is in milliseconds
real animationdelay=50; // original line 9
string ftimename;       // [CW fix]
ftimename = prefix +".tl";             // [CW fix]
for(int i=0; i < fits.length; ++i) {   // original line 105
// [CW fix; autoload a timeline file to fix PDF ordering error]
//    string s="\animategraphics["+options+"]{"+format("%.18f",1000/delay,"C")+
string s="\animategraphics["+options+**", timeline="+ftimename+"**]{"+format("%.18f",1000/delay,"C")+
  "}{"+basename();    // original line 129

But this really isn't a solution, it's just a work-around. The pattern of frame numbers in the timeline file makes it very clear what the problem is: the frame numbers are being sorted as if they're left-justified ASCII character strings and that's obviously not correct.

Okay, I'm doing this in (arggh) Windows 7, using MinGW (4/26/12), MiKTeX 2.9, with all packages up-to-date (Asymptote v2.21, Animate version 2012/12/06), ImageMagick v6.8.1-10, etc. Basically, everything works okay (well, making mp4 files isn't working but that's another issue); I can use TeXworks, latexmk, biblatex, hyperref, etc. and crank stuff out pretty much as I expect.

Now I can see these examples run on Asymptote's web page. So I create a VirtualBox Debian install (6.0.4), download TeX Live 2012 and install the whole thing. I don't update the packages, so it's Asymptote v2.16, Animate version 2012/05/04, ImageMagick v6.6.0-4, etc. Basically stuff that's 9 months older than what I'm using on Windows. And I try the various examples. And they work just fine.

So there is some difference in how Animate works on Windows as opposed to how it works on Linux. I would be interested in any suggestions as to how this can be fixed. Is it a bug that I should report? Do I have something messed up on my Win PC? I can make the timeline file when I need it to get the output I want, but that just becomes another step that I would rather avoid.

share|improve this question
add comment

1 Answer

The problem you describe is unrelated to the media9 package, only the animate package is involved in this Asymptote script.

I tried your example with a vanilla TeXLive-2012 on my Linux box, with packages updated using tlmgr update --all, prior to running asy on your code. animate is 6/12/2012, Asymptote is 2.16.

Everything works fine, with r running from 1 to 31.

enter image description here

I also tried an Asymptote-2.21 installation outside TeXLive with the same (correct) result.

share|improve this answer
Alex, thanks very much for responding. I apologize for my ignorance concerning LaTeX packages (I'm a noobie); you are right this is only Animate and Media9 is not involved (same author, I thought they were related). But this doesn't answer my question. Yes, it works just fine ON LINUX! That's why I spent some time setting up a Linux installation to test it. It only MESSES UP ON WINDOWS! That's why I'm wondering if it might have to do with MinGW, or path name orders, or something like that. –  Curtis White Feb 14 '13 at 4:19
Changed the original post title and other info to clarify that this is an Animate issue, not Media9; thanks Alex. –  Curtis White Feb 14 '13 at 4:27
I'll go and try MiKTeX. –  AlexG Feb 14 '13 at 8:00
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.