6

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.

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

1 Answer 1

9

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;

size(140mm,70mm,IgnoreAspect);
real[] x={1,3,4,5,6};
real[] y={1,5,2,0,4};
draw(graph(x,y,Hermite));
shipout("output01"); // save currentpicture to file named output01

currentpicture=new picture; // "clear the canvas"
size(140mm,70mm,IgnoreAspect);
real[] x2={1,2,3,4,5};
real[] y2={-3,1,9,2,4};
draw(graph(x2,y2,Hermite));
shipout("output02"); // save it
0

You must log in to answer this question.

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