4

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

Consider the following latex document test.tex:

\documentclass{minimal}
\usepackage{asymptote}
\def\asydir{asymptote}

\begin{document}

Testing Asymptote:

\begin{asy}
settings.outformat = "pdf";
unitsize(2cm);
draw((0,0) -- (1,0));
\end{asy}

\end{document}

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

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

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?

4

Just change the sub asy line in latexmrc to

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

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.