donRaphaco / neotex

latex live preview - plugin for neovim and vim 8
MIT License
177 stars 8 forks source link

Would you please add xelatex for UTF-8 support? #9

Closed y9c closed 6 years ago

y9c commented 6 years ago

I need to render file with Chinese characters.

donRaphaco commented 6 years ago

I added the option g:neotex_pdflatex_alternative which lets you change the latex executable. So if you set it to xelatex you should be good :)

y9c commented 6 years ago

thank you @donRaphaco

It works!

But setting neotex_latexdiff=1 can't trigger latexdiff .

donRaphaco commented 6 years ago

I think the problem is latexdiff doesn't detect the correct encoding. You can try to force the encoding with the --encoding flag on latexdiff, so setting g:neotex_latexdiff_options to --encoding=utf8 (or maybe utf-8-strict not sure what's the difference). I didn't test it myself, since I don't have the latex packages for Chinese typeset installed.

y9c commented 6 years ago

Hi @donRaphaco,

Thank you for your advice. I had modify encoding setting and delete Chinese characters in the file, but both method do not work.


I test on a machine running arch linux system.

 $ latex --version 

pdfTeX 3.14159265-2.6-1.40.18 (TeX Live 2017/Arch Linux)
kpathsea version 6.2.3
Copyright 2017 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.34; using libpng 1.6.34
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with poppler version 0.61.1

$ xelatex -version  

XeTeX 3.14159265-2.6-0.99998 (TeX Live 2017/Arch Linux)
kpathsea version 6.2.3
Copyright 2017 SIL International, Jonathan Kew and Khaled Hosny.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the XeTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the XeTeX source.
Primary author of XeTeX: Jonathan Kew.
Compiled with ICU version 60.2; using 60.2
Compiled with zlib version 1.2.11; using 1.2.11
Compiled with FreeType2 version 2.9.0; using 2.9.0
Compiled with Graphite2 version 1.3.10; using 1.3.11
Compiled with HarfBuzz version 1.7.5; using 1.7.6
Compiled with libpng version 1.6.34; using 1.6.34
Compiled with poppler version 0.61.1
Compiled with fontconfig version 2.12.6; using 2.12.6

 $ latexdiff --version      

This is LATEXDIFF 1.2.1  (Algorithm::Diff 1.15 so, Perl v5.26.1)
  (c) 2004-2017 F J Tilmann

I wonder how can NeoTex detect difference in the tex file. latexdiff requires two files as input, but there is only one file open. If NeoTex save the old version into an tempfile, which version is regarded as the original one. If I keep saving while editing the file, does the original version keep updating either?

donRaphaco commented 6 years ago

Hmm I don't know what you can do then :confused:

How NeoTex works: Every time you edited something the contents of the buffer are saved to a temp file, then latexdiff gets called with the saved file and the tempfile as inputs. The output is saved into another tempfile, which then gets compiled by pdflatex/xelatextex. So latexdiff highlights the diffrences between the version in the current buffer and the last saved version of your latex code.