0

I am trying to use latexmk with asymptote. I have a file called latextest.tex and a folder called build in the current directory. The contents of latextest.tex are as follows:

\documentclass{article}
\usepackage{asymptote}
\def\asydir{build}
\begin{document}
Hello World.
\begin{asy}
    size(7cm);
    pair A = dir(120);
    pair B = dir(210);
    pair C = dir(330);
    draw(A--B--C--cycle, red + 1.2);
\end{asy}
\end{document}

When I compile this file by running the following,

pdflatex latextest.tex
asy -o build/ build/latextest-1.asy
pdflatex latextest.tex

it compiles without any issue.

However, when I run latexmk latextest.tex, it produces the following error message.

Rc files read:
  /Users/kyawshinthant/.latexmkrc
Latexmk: This is Latexmk, John Collins, 29 May 2021, version: 4.74b.
Rule 'latex': File changes, etc:
   Changed files, or newly in use since previous run(s):
      'latextest.tex'
------------
Run number 1 of rule 'latex'
------------
------------
Running 'latex  -recorder  "latextest.tex"'
------------
Latexmk: Missing input file: 'build/latextest-1.eps' from following:
  'Package asymptote Warning: file `build/latextest-1.eps' not found on input line'
Latexmk: Missing input file: 'build/latextest-1.eps' from following:
  'Package asymptote Warning: file `build/latextest-1.eps' not found on input line 12.'
Latexmk: Log file says output to 'latextest.dvi'
Rule 'cusdep asy eps build/latextest-1': The following rules & subrules became out-of-date:
      'cusdep asy eps build/latextest-1'
------------
Run number 1 of rule 'cusdep asy eps build/latextest-1'
------------
Latexmk: In running custom-dependency rule
  to make 'build/latextest-1.eps' from 'build/latextest-1.asy'
  function 'run_asy' did not make the destination.
Collected error summary (may duplicate other messages):
  cusdep asy eps build/latextest-1: Command for 'cusdep asy eps build/latextest-1' gave return code -1
Latexmk: Use the -f option to force complete processing,
 unless error was exceeding maximum runs, or warnings treated as errors.

My .latexmkrc file is as follows:

sub run_asy {return system("asy -o build/ '$_'");}
add_cus_dep("asy", "eps", 0, "run_asy");
add_cus_dep("asy", "pdf", 0, "run_asy");
add_cus_dep("asy", "tex", 0, "run_asy");

It seems like there was a problem when executing my subroutine for converting from .asy to .eps. What could be going wrong here?

1 Answer 1

1

In defining the custom dependency, $_ should be replaced by $_[0], so that .latexmkrc contains:

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

You must log in to answer this question.

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