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.

4
  • 2
    Can you just use the Vim command line? :!lualatex % should do it.
    – Thruston
    Commented Jun 28, 2023 at 20:55
  • Add %!TeX program = xelatex as the first line of your file... then close and reopen it. Anyway, this question is probably better suited for the vi/vim site.
    – Rmano
    Commented Jun 28, 2023 at 21:13
  • :!lualatex % in principle works. I have some errors but i might fix them. Commented Jun 29, 2023 at 7:45
  • %!TeX program = xelatex worked as well. Thanks for solutions. Commented Jun 29, 2023 at 7:50

1 Answer 1

2

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?

1
  • Thank you very much. Commented Jun 30, 2023 at 10:35

You must log in to answer this question.

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