Vimtex: Chinese is not supported and failed to compile

Created on 25 Apr 2019  路  5Comments  路  Source: lervag/vimtex

While using package of CJKutf8 and trying to write Chinese in the document, the vimtex shows that Compilation failed with no any debug information.Here' s how I use the package and write the document, which is also the output of :VimtexCompileOutput.

\documentclass{article}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK}{UTF8}{song} 
<article content here>
\end{CJK}
\end{document}

While using English, the plugin works just as expected. Can this wonderful plugin support other language like Chinese while compiling the latex document? Thx!

Most helpful comment

The minimal example should in general also include a minimal vimrc file. However, I will try to reproduce with your LaTeX sample.

Note: You are making several mistakes here:

  1. g:vimtex_complier_latexmk_engines: It's compiler, not complier, further, the option should specify a dictionary similar to the one in the documentation, see :help vimtex_compiler_latexmk_engines. To change the default, you should change the _ entry.

  2. The TeX program directive is respected by vimtex, but you should change TX to TS. You can also simply write %!TEX program = xelatex. See :help vimtex-tex-program.

All 5 comments

I'm sorry, but this is not a vimtex issue (I believe). If you want me to help debug it, then please provide a full minimal example.

You did not provide the output of :VimtexCompileOutput. You can also inspect the output of :VimtexErrors after vimtex says "Compilation failed". This might give some clues to what is wrong.

Thx. And actually I'm now trying to use xelatex as the latexmk engine, and by using the package of ctex to achieve Chinese supporting. In the ~/.vimrc, I just use this line to set the engine to xelatex,

let g:vimtex_complier_latexmk_engines ='xelatex'

after that, the :VimtexInfo gives this,

    compiler: latexmk
    backend: jobs
    output: /var/folders/kh/cm4b878s16j3_cgttq5_pcl00000gn/T/vyPsd8o/2
    configuration: 
      continuous: 1
      callback: 1
      latexmk options:
        -verbose
        -file-line-error
        -synctex=1
        -interaction=nonstopmode
      latexmk engine: -pdf
    job: process 80667 run
    cmd: max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -view=none -e '$success_cmd = "echo vimtex_compiler_callback_success"' -
    viewer: Skim
    qf: LaTeX logfile
    config: 
      fix_paths: 1
      packages: 
        default: 1
      default: 1
     document class: article

which shows that the latexmk engine is still -pdf.

The full minimal example is

%!TEX TX-program = xelatex
\documentclass{article}
\usepackage[UTF8]{ctex}
\begin{document}
Hello World!
涓枃     %here is the Chinese part.
\end{document}

The error information is

/usr/local/texlive/2018/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-mac.def|47 error| Critical ctex error: "fontset-unavailable"
test.tex|| CTeX fontset `mac' is unavailable in current mode.
test.tex|| See the ctex documentation for further information.
test.tex|| For immediate help type H <return>.

It seems that the only problem I have to solve is that how to change latexmk engine into xelatex. Thx!

The minimal example should in general also include a minimal vimrc file. However, I will try to reproduce with your LaTeX sample.

Note: You are making several mistakes here:

  1. g:vimtex_complier_latexmk_engines: It's compiler, not complier, further, the option should specify a dictionary similar to the one in the documentation, see :help vimtex_compiler_latexmk_engines. To change the default, you should change the _ entry.

  2. The TeX program directive is respected by vimtex, but you should change TX to TS. You can also simply write %!TEX program = xelatex. See :help vimtex-tex-program.

That's great. Now I totally understand what happened. The problem is solved now, and Chinese is perfectly supported. Much appreciate!

Great, happy to hear that it works. :)

Was this page helpful?
0 / 5 - 0 ratings