LuaTex、Xelatex 与 VimTex

LuaTex、Xelatex 与 VimTex

我正在尝试使用 vimtex 中的格鲁吉亚语。我发现我必须使用 XelaTex 或 LuaTex 进行编译,但我不知道如何让 vimtex 与它们一起编译。我想保留默认编译器并将 Xelatex 添加为可选项,可以吗?我尝试阅读官方文档,但我看不懂太多内容。

答案1

无需触及默认值,您就可以使用vimtex“魔术注释” 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]

请注意以下几点:

  1. 如果你改变“魔术评论”,你必须重新加载插件确认它(\lx如果您没有更改领导者角色,则标准按键是)。

  2. xelatex不是程序名称;它是一组在其他地方定义的配置的标签。最常见的是xelatexlualatex。在这里使用通用命令可能会妨碍所需的所有安全措施--shell-escape

  3. vim如果你执行,则会直接显示更多信息: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:何时以及为什么应该使用 % !TEX TS 程序和 % !TEX 编码?

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

没有直接关系,但你可能也会对此感兴趣:我如何启用 shell-escape?

相关内容