0

I am currently using latex on vim with the vimtex plugin (with mac big sur os), and there are two features I would like to have:

  1. Asymptote compiles automatically when I compile latex
  2. All auxiliary files (.aux, .fls, etc. and also asymptote files like file-1.asy, file-1.pdf etc.) would be organized in a separate "build" directory

In my .vimrc file, I have the following specified under the vimtex plugin, which moves all auxiliary files (.aux, .fls, etc. as well as the .asy files) to a separate "build" directory.

Plug 'lervag/vimtex'
    let g:tex_flavor='latex'
    let g:vimtex_view_method='skim'
    let g:vimtex_quickfix_mode=0
    let g:vimtex_compiler_latexmk = {
                \ 'build_dir' : 'build',
                \}
    set conceallevel=1
    let g:tex_conceal='abdmg'

The asymptote files (file-1.asy, file-1.pdf, etc.) are automatically moved to the build directory as desired. However, the asymptote doesn't compile automatically when latex is compiled.

So, in my .latexmkrc file, I have the following which enables the asy to automatically compile when I compile the tex document (successfully).

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");

However, this only works when I don't specify the build directory in the .vimrc file, i.e. when working with conjunction with the following line, it fails.

let g:vimtex_compiler_latexmk = {
            \ 'build_dir' : 'build',
            \}

Essentially, I am able to get each of the two features I desire on their own, but I can't get both to work at the same time. Is there any way I can have both features work together?

0

Ran into this issue too on Linux.

In your .latexmkrc, use

sub asy {return system("asy -outname \$(dirname '$_[0]')/build '$_[0]'");}

instead of

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

It might be a good idea to configure the build directory of latexmk directly in your .latexmkrc instead of .vimrc with

$out_dir="build";

This way we can instead do

sub asy {return system("asy -outname \$(dirname '$_[0]')/$out_dir '$_[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.