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)?

  • 1
    To recompile tex without recompiling unchanged images, use asypictureB. Jun 26, 2020 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?
    – boink
    Jun 28, 2020 at 0:38
  • @CharlesStaats Can you turn your comment into a response?
    – AndréC
    Jun 28, 2020 at 5:43

2 Answers 2


You can use latexmk with asymptote.sty to recompile only the pictures that have changed, using the configuration file latexmkrc or latexmkrc_asydir that ships with asy.

  • 2
    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, 2020 at 11:03

To recompile tex without recompiling unchanged images, you can use asypictureB.

  • Interesting. Can you give a minimal example of how to use your package?
    – AndréC
    Jun 28, 2020 at 12:40
  • @Charles Staats: from your package "Users are permitted and strongly encouraged to specify a distinct name for each Asymptote image in the file. Distinctly named Asymptote images are not recompiled if their code has not changed since the last latex run.". I suggest taking the time of the first compiling for names, so naturaly they are disctint!
    – Black Mild
    Jan 29, 2021 at 20:57
  • 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, 2021 at 21:10

You must log in to answer this question.

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