1

I cant seem to find a way to support all the CJK (Chinese, Japanese and Korean) lanaguages in one document.

Yes you can apply something like \ch{...} to render Chinese for example, however, is there a way to have it render the content without applying commands to the content. For example, how can I get the below to work without either some of the characters missing or square white boxes appearing on some characters

\documentclass{article}
\usepackage{xeCJK}

\begin{document} Japanese: フォントはまた、数学的な形態および他の環境で使用することができるフォントはまた、数学的な形態および他の環境で使用することができる Chinese: 关于数学部分 Korean: 전체 문서에 대한 기본 정보를 소개 단락. \end{document}

I would like to add one or more CJK content without having to apply commands for each of the languages.

I am happy to use XeLaTeX, LuaLaTeX etc... I have been playing with XeLaTeX as this supports characters better than others but I can't seem to get it to work.

I have spent a lot of time on this going around in circles and not be able to find a good solution without characters missing or white boxes appearing.

Help would very much be appreciated.

root92
  • 125

1 Answers1

1

Only a partial answer since I don't know enough about these languages to help with proper language support like e.g. linebreaking. (You might want to look at babel and/or luatexja for that)

If you only need the font support to avoid missing characters you can use the multiscript font feature in LuaLaTeX: (This example requires Noto Serif CJK to be installed, but you can add four others fonts instead.)

\documentclass{article}
% You probably need luatexja and/or babel for linebreaking
% But here we will cheat for now and just use larger paper:
\usepackage[margin=1cm,a3paper]{geometry}

\directlua{ \directlua { luaotfload.add_multiscript("cjk", { Hang = "Noto Serif CJK KR:mode=node;script=hang;", Hani = "Noto Serif CJK TC:mode=node;script=hani;", Kana = "Noto Serif CJK JP:mode=node;script=kana;", Hira = "Noto Serif CJK JP:mode=node;script=hira;", } ) } } \usepackage{fontspec} \setmainfont[RawFeature={multiscript=cjk}]{Noto Serif} \begin{document} Japanese: フォントはまた、数学的な形態および他の環境で使用することができるフォントはまた、数学的な形態および他の環境で使用することができる

Chinese: 关于数学部分

Korean: 전체 문서에 대한 기본 정보를 소개 단락. \end{document}

enter image description here

  • I have tried to run the above in Overleaf but it takes too long to compile which then timesout. – root92 Jul 06 '21 at 20:37
  • Also is there a way to get the same thing to work but for either xelatex or pdflatex? – root92 Jul 06 '21 at 20:43
  • @DanMaia It should work on Overleaf if you replace all four instances of mode=node with mode=harf. – Marcel Krüger Jul 06 '21 at 20:53
  • Ah thank you. What is the difference between the two modes? If this is run off a command line which mode should it be on? – root92 Jul 06 '21 at 21:39
  • @DanMaia For CJK it doesn't really matter. harf uses HarfBuzz for text shaping which is especially for very complicated scripts (arabic, indic, ...) more reliable but the LuaTeX integration is newer and therefore less tested. node is the traditional font shaping in LuaLaTeX which is imported from ConTeXt and written completely in Lua. It is sometimes more customizable (e.g. you can add ligatures/change kerning etc.) and very well integrated. For big fonts like this, it has to parse the full font at the first run though, therefore it can lead to issues as you experienced with Overleaf. – Marcel Krüger Jul 06 '21 at 21:56
  • I am trying to run this via command line for lualatex but I am getting: (/usr/share/texlive/texmf-dist/tex/latex/base/ifthen.sty))[\directlua]:1: attem pt to call field 'add_multiscript' (a nil value) stack traceback: [\directlua]:1: in main chunk. l.118 } – root92 Jul 08 '21 at 12:56
  • The command I am running is: lualatex *.tex – root92 Jul 08 '21 at 12:57
  • @DanMaia Probably your TeX Live version is too old, add_multiscript was added in February 2020, so it needs either at least TeX Live 2020 or maybe TeX Live 2019 with all updates installed. Your path looks like a distribution packaged TeX Live version, they are often rather old. – Marcel Krüger Jul 08 '21 at 13:05
  • Is texlive-base sufficient? Side note, the 2020 version is in testing (buster) how long before it's moved from testing to stable? – root92 Jul 08 '21 at 13:25
  • @DanMaia Since I don't know which distribution you use except that it's not one which I use (since there is no package texlive-base in Arch) I can't tell you which you need and/or when/if they get updated. – Marcel Krüger Jul 08 '21 at 13:27
  • Thank you. Out of curiosity, is there a way to the same thing as above for pdflatex? – root92 Jul 08 '21 at 16:58
  • @DanMaia Since in pdfTeX fonts can't contain more than 256 characters any attempt to implement CJK there (even for just one language) has to combine a lot of fonts anyway, so adding some additional glyphs for other languages shouldn't be too hard. I don't know if anyone ever did that though, so you might need to implement it yourself. – Marcel Krüger Jul 08 '21 at 17:09
  • Is it possible to download the .sty and .lua files https://www.ctan.org/pkg/luaotfload to make it work in 2018? If so, which .lua file would I need? – root92 Jul 08 '21 at 17:37
  • @DanMaia No, the current luaotfload version is incompatible with such old versions of luatex. But you can install a newer version of TeX Live instead. – Marcel Krüger Jul 08 '21 at 18:43