18

Searching through tex.stackexchange.com, I've come to understand that xetex is currently the preferred engine for documents that include Chinese characters. In xetex, one simply uses the xeCJK or ctex packages and start including the characters in the body of the document. But it appears these two packages don't work with luatex.

So is it possible to include Chinese characters in a document using luatex? I cannot find a single example of this.

ana
  • 481
  • You can include Chinese characters, but for a full fledged support of Chinese, I don't think there are good tools with LuaLaTeX. – egreg Jan 13 '15 at 18:54

2 Answers2

19

Just use luatexja. The Chinese TeX community decide not to develop a new package but use luatexja, because the tools designed for Chinese and Japanese usually work the same.

The developer version of our ctex package will provide a Chinese customized interface for luatexja. Now you can use luatexja directly.

Here is an example:

enter image description here

% !TEX encoding = UTF-8
% !TEX program = lualatex
\documentclass{article}
\usepackage{luatexja-fontspec}
\setmainjfont{FandolSong}
\begin{document}

在 Lua\TeX{} 中正常地使用中文。获得自动的\textbf{字体选择},标点“压缩”,以及正确的断行处理等特性。

\end{document}

Note: fontspec alone is insufficient. You need proper line breaking, punctuation kerning and font switching features provided by luatexja.

Leo Liu
  • 77,365
  • 3
    Six and a half years later, is this still the proper way? I’m considering to switch from xelatex (I’m very happy with xecjk) to lualatex and I’m not sure where to start. – Philipp Sep 10 '21 at 19:52
  • 1
    Is luatexja "neutral" to the non-CJK part? I ask this question because I want to use Japanese a little bit within my otherwise English documents. – Ryo Sep 28 '22 at 07:26
  • luatexja is not as good as xeCJK. – yanpengl May 25 '23 at 08:39
  • \textit doesn't seem to work in this context, are there any solutions to this? – FR09 Jun 21 '23 at 01:44
3

very basic use would be

enter image description here

\documentclass{article}
\usepackage{fontspec}
\setmainfont{MS PGothic}
\begin{document}
我希望這是,翻譯是由谷歌提供的中國文字。
\end{document}
David Carlisle
  • 757,742
  • 1
    Maybe, for short Chinese inserts, \newfontfamily is better. – egreg Jan 13 '15 at 18:56
  • Thanks. I understand there is a setCJKmainfont in xeCJK. Does this command exist in lualatex? I'd like to use separate fonts for English and Chinese if possible. – ana Jan 13 '15 at 19:33
  • I understand I can use \newfontfamily but that would mean I have to explicitly indicate when to switch to a Chinese font. With setCJKmainfont it switches automatically. – ana Jan 13 '15 at 19:39
  • @ana sorry I don't know too much about available CJK packages, I just wanted to demonstrate that basic typesetting of text was easy enough with fontspec package an luatex. – David Carlisle Jan 13 '15 at 19:57
  • @ana xeCJK uses various XeTeX mechanisms with direct correspondence in LuaTeX, and therefore you cannot really have proper CJK typesetting with LuaTeX at this time. See Is there a LuaTeX analogue to XeTeXinterchartoks? – Alan Munn Jan 14 '15 at 00:02
  • 1
    It won't work if you type more characters. The line break algorithm designed for western languages doesn't work for East Asian languages. – Leo Liu Jan 24 '15 at 15:33