1

I know you can apply something like \ch{...} to render specific language such as Chinese, however, is there a way to have it render the content without applying commands to the content but also work in LuaLaTeX or XeLaTeX 2018 version (latest stable version).

For example, how can I get the below to work without characters missing, square white boxes appearing on some characters, and be used in the 2018 version of latex?

\documentclass{article}
\usepackage{xeCJK}

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

Help would very much be appreciated.

5
  • The characters are done by the font(s) you use. You need to have suitable fonts.
    – Cicada
    Commented Jul 9, 2021 at 15:05
  • 1
    2018 is not the "latest stable version". Why don't you install a current texlive as suggested in your other question tex.stackexchange.com/q/603929/2388? Commented Jul 9, 2021 at 15:12
  • According to Debian page buster (stable) is 2018.2019
    – root92
    Commented Jul 9, 2021 at 15:26
  • @DanMaia That page refers to the Debian packages with a selection of TeXLIve, not to TeXLive itself. The Debian packages are clearly outdated. Commented Jul 9, 2021 at 15:44
  • Oh.. at the moment I have installed texlive-latex-base="2018.20190227-2" texlive-fonts-recommended="2018.20190227-2" texlive-fonts-extra latex-cjk-* so I guess installing the latest TexLive, would I still need ``texlive-latex-base`?
    – root92
    Commented Jul 9, 2021 at 16:13

2 Answers 2

3

UPDATE: Hopefully, the following code takes care of the missing characters.

\documentclass{article}
\usepackage{parskip}
\usepackage[fallback]{xeCJK}
\setCJKmainfont[BoldFont=HaranoAjiMincho-Bold.otf]{HaranoAjiMincho-Regular.otf}
\setCJKfallbackfamilyfont{\CJKrmdefault}{gulim.ttf}
\begin{document}
Japanese:
読サ統転ン務6危キリイ日記属して帯記ネヌイナ分碁モチワエ返地ゅびはン広沼とおは通国ふま指区ロウイ観提ニユ族曲トク車也むンり拡極保なにづか揚状侍勃ねラび。操みん強智そた締窟ねぴ悪6上手ルぜづて種当止タセ説当ね読寮クや減8様ケリトク認川るす差禁音策きがぜえ足94練ぴむびょ。

Japanese: フォントはまた、数学的な形態および他の環境で使用することができるフォントはまた、数学的な形態および他の環境で使用することができる

Chinese: 关于数学部分 

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

enter image description here

====== Below is my original attempt via TeX Live 2021 with all packages updated:

\documentclass{article}
\usepackage[fallback]{xeCJK}
\setCJKmainfont[BoldFont=FandolSong-Bold.otf]{FandolSong-Regular.otf}
\setCJKsansfont[BoldFont=FandolHei-Bold.otf]{FandolHei-Regular.otf}
\setCJKmonofont{FandolFang-Regular.otf}
\newCJKfontfamily\kaiti{FandolKai-Regular.otf}
\setCJKfallbackfamilyfont{\CJKrmdefault}{gulim.ttf}
\begin{document}
Japanese: フォントはまた、数学的な形態および他の環境で使用することができるフォントはまた、数学的な形態および他の環境で使用することができる

Chinese: 关于数学部分 

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

enter image description here

My answer is obtained from combining the information at How do I find out what Chinese fonts are installed with my MacTeX installation? and Combining Chinese, Japanese and Korean text with xeCJK.

5
  • I am still seeing missing characters with this, in particular 悪読転様観 the full text I used to test is 読サ統転ン務6危キリイ日記属して帯記ネヌイナ分碁モチワエ返地ゅびはン広沼とおは通国ふま指区ロウイ観提ニユ族曲トク車也むンり拡極保なにづか揚状侍勃ねラび。操みん強智そた締窟ねぴ悪6上手ルぜづて種当止タセ説当ね読寮クや減8様ケリトク認川るす差禁音策きがぜえ足94練ぴむびょ。
    – root92
    Commented Jul 12, 2021 at 15:16
  • @DanMaia, I updated my answer. Please see if the missing characters are taken care of.
    – citsahcots
    Commented Jul 12, 2021 at 16:26
  • These characters are missing 测试
    – root92
    Commented Jul 12, 2021 at 17:08
  • I am running out of tricks..
    – citsahcots
    Commented Jul 12, 2021 at 17:13
  • I have got a solution, but I am struggling to install texlive for lualatex via the command line. At the moment I have lualatex on texlive 2019 but I need 2020
    – root92
    Commented Jul 12, 2021 at 17:38
2

It’s not possible to do that correctly without language tagging. The original sin of Unicode was thinking that 16 bits could be enough. To try to make that work, the Unicode Consortium assigned the same codepoints to Chinese characters and Japanese Kanji (and also traditional Korean and Vietnamese forms of the same Chinese characters). Then they had to abandon 16 bits anyway, leaving them with a worst-of-both-worlds compromise.

You can tag multiple ideographic scripts in babel or polyglossia. This sample requires you to download the Noto CJK fonts and compile in LuaLaTeX or XeLaTeX.

\documentclass{article}
\tracinglostchars=3 % Make it an error if characters are missing.
\usepackage[english]{babel}
\usepackage{parskip}

\babelprovide[import]{japanese}
\babelprovide[import]{korean}
\babelprovide[import=zh-hant]{chinese} % Or zh-hans for Simplified Chinese

\babelfont{rm}
          {Noto Serif}
\babelfont[chinese]{rm}
          [Renderer=HarfBuzz]{Noto Serif CJK tc}
\babelfont[japanese]{rm}
          [Renderer=HarfBuzz]{Noto Serif CJK jp}
\babelfont[korean]{rm}
          [Renderer=HarfBuzz]{Noto Serif CJK kr}

\begin{document}
Japanese: \foreignlanguage{japanese}{フォントはまた、数学的な形態および他の環境で使用することができるフォントはまた、数学的な形態および他の環境で使用することができる}

Chinese: \foreignlanguage{chinese}{关于数学部分}

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

Noto CJK sample

If you try to auto-detect all three languages, you get this:

\documentclass{article}
\tracinglostchars=3 % Make it an error if characters are missing.
\usepackage[english]{babel}
\usepackage{parskip}

\babelprovide[import, onchar=fonts ids]{japanese}
\babelprovide[import, onchar=fonts ids]{korean}
\babelprovide[import=zh-hant, onchar=fonts ids]{chinese} % Or zh-hans for Simplified Chinese

\babelfont{rm}
          {Noto Serif}
\babelfont[chinese]{rm}
          [Renderer=HarfBuzz]{Noto Serif CJK tc}
\babelfont[japanese]{rm}
          [Renderer=HarfBuzz]{Noto Serif CJK jp}
\babelfont[korean]{rm}
          [Renderer=HarfBuzz]{Noto Serif CJK kr}

\begin{document}
Japanese: フォントはまた、数学的な形態および他の環境で使用することができるフォントはまた、数学的な形態および他の環境で使用することができる

Chinese: 关于数学部分 

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

Noto fonts sample

If you switch between this image and the one above, you will see that Kanji are displayed in their traditional Chinese forms. If you had loaded Japanese last, the Chinese characters would be displayed in their Japanese forms instead.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .