2

I'm trying use the asymptote package with vimtex, it's the first time I try it. When I try to compile, the figure doesn't appear at all in the pdf. This is an example code I found to test:

\usepackage[inline]{asymptote} % I've also tried without [inline] but I get the same results
...
\begin{asy}
    settings.outformat = "pdf";
    defaultpen(fontsize(10pt));
    label("Hello world!");
\end{asy}

The only warning I get is

Package asymptote Warning: file `***-1.pdf' not found on input line 30.

The myfile-*.asy files do appear in the folder.

I found this issue in the vimtex github where they suggest using a latexmkrc file with

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

I tried putting this file in the folder I'm working on but it makes the vimtex compilation fail inmediately.

Update:

Running asy myfile-1.asy in the terminal returns this error:

no matching variable 'byteinv'
no matching variable '_schur'

To fix this I've manually updated to 2.85, because was using the MiKTeX version 2.81 which didn't work properly. Now it works if I run asy myfile-1.asy manually, but vimtex doesn't do it automatically.

11
  • 1
    Welcome to TeX.SE!
    – Mensch
    Mar 27 at 21:41
  • 1
    Does your compilation generate myfile-*.asy type files in the working directory? Does latexmk generate any other myfile-* files with a different extension? What does running which asy in a terminal give you?
    – Dai Bowen
    Mar 29 at 13:06
  • @DaiBowen myfile-*.asy do generate in the folder, nothing else besides the usual .log, .out, etc. Running which asy returns "which" isn't recognized as a command. I tried in Windows cmd, not sure if that's the right place
    – DavidCA
    Mar 29 at 19:31
  • 1
    Ah, Windows (I'm assuming you're not using WSL then), can you try Get-Command asy in Windows PowerShell (not command prompt), it should give one hit, matching Get-Command pdflatex? If that looks good, try running asy myfile-*.asy from the prompt after navigating to your working directory and see what it does.
    – Dai Bowen
    Mar 29 at 19:47
  • 1
    Ah, that's beyond me, but sounds like you just need to replace the MiKTeX installed asymptote and then as long as you can get it on your path to run asy myfile-*.asy then latexmk/vimtex should just work
    – Dai Bowen
    Mar 29 at 22:42

1 Answer 1

1

The problem is the .asy files can't compile because apparently the MiKTeX distribution of Asymptote doesn't have compatible files and executable, as pointed out here. Instead, download and install Asymptote from here and copy the files from C:\Program Files\Asymptote (not sure if you need all the files but it works for me) into the same directory as the incompatible version (C:\Users\David\AppData\Local\Programs\MiKTeX\miktex\bin\x64 in my case) (there might be another way to use the correct executable without copying the files, but that's beyond my knowledge). I think you also need to rename the asy.exe file you copied to miktex-asy.exe.

Now you can compile the .asy files by executing them with the Asymptote program or in a terminal with asy myfile-*.asy.

Vimtex uses latexmk by default. In order to automatically compile the myfile-*.asy files when compiling with vimtex, you need to add a .latexmkrc file in the directory you're working on with the following:

sub asy {return system("asy \"$_[0]\"");}
add_cus_dep("asy","eps",0,"asy");
add_cus_dep("asy","pdf",0,"asy");
add_cus_dep("asy","tex",0,"asy");
1
  • Best should be to get the C:\Program Files\Asymptote exe on path (might be automatic and just require a restart or be an install option), and then uninstall asymptote within MiKTeX.
    – Dai Bowen
    Apr 16 at 0:21

You must log in to answer this question.

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