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?


Just change the sub asy line in latexmrc to

sub asy {return system("asy -o \"$_[0]\" \"$_[0]\"");}
| improve this answer | |

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.