7

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?

1 Answer 1

6

Just change the sub asy line in latexmrc to

sub asy {return system("asy -o \"$_[0]\" \"$_[0]\"");}
1
  • 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
    Jan 1 at 16:40

You must log in to answer this question.

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