One of the features I've liked in metapost and missed in asymptote is the fact that (in metapost) I can write the code for many figures in a single file. metapost then generates indexed set of figures once compiled. For documents with many figures this is very useful feature. Can anyone confirm that this is not possible in asymptote. Thanks.

  • Please clarify what is meant by an "indexed set of figures". Are these files with names like foo-1.eps, foo-2.eps, etc.? – Charles Staats Aug 8 '15 at 6:11
  • foo.1, foo.2 (with metapost these are not stand alone eps) – Moez K Aug 9 '15 at 17:53

Welcome to TeX.SE, you can put as many figures in a single file as you wish but you'll need to draw each into a seperate picture, you can do this simply by creating a new picture object at the start of each figure and assigning it to currentpicture. For each figure, you'll need to explicitly call shipout with the desired output filename.

If you compile the following examples with asy -f pdf you'll end up with two files named output01.pdf and output02.pdf, one per figure.

// Figure 1
currentpicture=new picture; // For the first figure, you can skip this
import graph;

real[] x={1,3,4,5,6};
real[] y={1,5,2,0,4};
shipout("output01"); // save currentpicture to file named output01

currentpicture=new picture; // "clear the canvas"
real[] x2={1,2,3,4,5};
real[] y2={-3,1,9,2,4};
shipout("output02"); // save it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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