I am trying out Asymptote with latexmk and I would like to automate the interaction.

Consider the following latex document test.tex:



Testing Asymptote:

settings.outformat = "pdf";
draw((0,0) -- (1,0));


In my latexmkrc I have the following lines for Asymptote integration:

sub asy {return system("asy -o asymptote/ \"$_[0]\"");}

Running latexmk -pdf test.tex generates test.pdf in the current folder and test-1.asy and test-1.pdf in the asymptote folder -- but only if

  • I manually created the asymptote folder prior to running latexmk.
  • The folder specification in the latex document (\def\asydir{asymptote}) and latexmkrc (-o asymptote/) are identical.

I would like latexmk to read asydir from the main tex file, create the directory if it does not exist and run asy with the read output folder.

Is this possible?

1 Answer 1


Just change the sub asy line in latexmrc to

sub asy {return system("asy -o \"$_[0]\" \"$_[0]\"");}
  • Actually this doesn't answer the stated question at all, does it? If asymptote/ folder doesn't exist in the first place then it won't be created.
    – user202729
    Commented Jan 1 at 16:40

You must log in to answer this question.

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