2

I'm trying to use Georgian language with vimtex. I found out that I have to compile with XelaTex or LuaTex but i don't know how to make vimtex to compile with them. I would like to keep default compiler and add Xelatex as optional, is it possible? I have tried to read official documentation but I can't understand much.

Rmano
  • 40,848
  • 3
  • 64
  • 125

1 Answers1

1

Without touching the default, you can use, in vimtex, the "magic comment" TeX program:

%! TeX program = xelatex
\documentclass{article}
\usepackage{iftex}
\begin{document}
I have been compiled with\dots{\ttfamily
\ifluatex
    luatex
\else\ifxetex
    xetex
\else\ifpdftex
    pdftex
\else
    NO IDEA!
\fi\fi\fi}

\end{document}[![enter image description here][1]][1]

Notice a couple of things:

  1. if you change the "magic comment", you have to reload the plugin to acknowledge it (the standard keystrokes are \lx, if you didn't change the leader char).

  2. the xelatex there is not a program name; it's a label for a set of configurations defined elsewhere. The most common ones are xelatex and lualatex. Using a generic command here can hinder all the security things that makes --shell-escape needed.

  3. there is much more info directly in vim if you execute :h vimtex-tex-directives:

SUPPORT FOR TEX DIRECTIVES                              *vimtex-tex-directives*

VimTeX supports two of the commonly used TeX directives [0]: the TeX root and the TeX program directive. The TeX root directive was already described above, see |vimtex-tex-root|.

                                                       *vimtex-tex-program*

The TeX program directive works by specifying the TeX compiler program in a comment in one of the first lines of the main project file. It is parsed only when it is required by a compiler backend.

The syntax is best explained with an example: >latex

%! TeX program = lualatex %! TEX TS-program = xelatex

The left-hand side must contain the text "tex program" or "tex ts-program" and as with |vimtex-tex-root|, the words are recognized regardless of casing and the spaces are ignored. The right-hand side must correspond to a key in the |g:vimtex_compiler_latexmk_engines| or |g:vimtex_compiler_latexrun_engines| dictionaries. See also [0,1].

0: When and why should I use % !TEX TS-program and % !TEX encoding?

1: https://github.com/lervag/vimtex/issues/713

Not directly related, but you probably can also be interested in this: How can I enable shell-escape?

Rmano
  • 40,848
  • 3
  • 64
  • 125