benbrastmckie / .config

NeoVim configuration optimized for writing in LaTeX
318 stars 251 forks source link

enable VimtexCompile to run xelatex #111

Open ammukuttu opened 10 months ago

ammukuttu commented 10 months ago

How can the base latex compile routine (VimtexCompile) be modified to execute xelatex instead of latex. For projects that have fontspec dependency, latexmk gives several errors. The same file compiles by running xelatex on a terminal without errors.

A few options have been suggested in the Internet. One of them is (non-lua):

let g:vimtex_compiler_latexmk = { 
        \ 'executable' : 'latexmk',
        \ 'options' : [ 
        \   '-xelatex',
        \   '-file-line-error',
        \   '-synctex=1',
        \   '-interaction=nonstopmode',
        \ ],
        \}

This option when adapted and placed in vimtex.lua should work. I was however not able to get it to work.

Another option was to introduce a .latexmkrc file. This approach also didn't work.

$pdflatex = "xelatex %O %S";
$pdf_mode = 1;

Finally the only option that worked was changing the source file with this line in its header: %!TeX program = xelatex

While this approach works, it is a problem because for situations like mine, where I'm writing a book, each chapter is a separate source that gets developed independently. This has to be added for every file.

Is there a way to get this mod done permanently inside vimtex.lua or any other .lua file ?