# Is it better to use Asymptote in-document vs compiling separately?

I write files with a fair amount of Asymptote in them and I have developed the habit of writing the asy code in a separate file, rendering it as a pdf (usually; sometimes it's a different format), and then using \includegraphics to put the image into my tex file.

I know that this can be done inline with \usepackage{asymptote} and \begin{asy}...\end{asy}, but I stopped doing this after I had to do a 3d-heavy paper. Each time I wanted to compile my tex file, I had to recompile all the images, and that took upwards of 15 minutes at times. I feel like I've since seen a method to recompile tex without recompiling all the Asymptote images, but I don't quite remember it anymore (if anyone can point it out, that'd be fantastic!).

But the main question I had was: Is it considered bad practice to do what I do (compile Asymptote separately, as opposed to putting the Asymptote code inline)?

• To recompile tex without recompiling unchanged images, use asypictureB. Jun 26 '20 at 19:09
• @CharlesStaats Oh yes—I think that's the one I'd seen; thanks! I still do wonder though: Is there a general preference to use Asymptote in-document? Jun 28 '20 at 0:38
• @CharlesStaats Can you turn your comment into a response? Jun 28 '20 at 5:43

• One limitation of this approach: if you add or remove an image, all the subsequent images will be recompiled. This was one of my primary motivations to create asypictureB. Jun 28 '20 at 11:03
To recompile tex without recompiling unchanged images, you can use asypictureB.
• Assuming you save that information in an auxiliary file, how do you determine later on which image a given name corresponds to? (Assuming that e.g. images have switched order or been inserted in the middle.) Also, having readable image names can make it easier to do things like switch over to an \includegraphics model for a publisher who does not support Asymptote. Jan 29 at 21:10