1

I have the following document:

\documentclass[12pt,a4paper,oneside]{scrbook}
\usepackage{fontspec}
\makeatletter
\usepackage{csquotes}
\usepackage{luacode}
%\usepackage[UTF8]{ctex}
\usepackage{luatexja-fontspec}
\usepackage{polyglossia}
\setdefaultlanguage[variant=american]{english}
%\setotherlanguage{chinese}
\usepackage{xstring}
\defaultfontfeatures{Mapping=tex-text}
\newfontfamily\chinesefont[Path=/usr/share/fonts/arphicfonts/]{UMing}

\makeatother

\begin{document}

The common transliteration of 易经 is {\enquote{I Ching,}} 
following the now-obsolete Wade-Giles system: modern Romanization 
of almost all modern Chinese texts follows the Hanyu Pinyin standard used here. 
See [huang].

\end{document}

When I try to typeset it, the second Chinese character does not typeset correctly (I get a box with an X in it). This is not the only instance where a character fails to be typeset corretcly. If I uncomment the line for ctex, the Chinese renders correctly, but all the English is typeset wrong. As far as I know, polyglossia does not support Chinese. I have a large document with a lot of brief snippets of Chinese and Japanese text, but the main document language is English (other languages include polytonic Greek, French, Latin, Italian, Russian, and, uh … "voynich"). I was told that lualatex was better at typesetting multiple languages, but I can't get this to work. Suggestions?

3
  • if you can't get polyglossia to work, you may consider babel. See github.com/latex3/babel/blob/master/news-guides/guides/… . Feb 27, 2021 at 19:58
  • It's nearly 500 pages of text, with thousands of quotes in other languages. I'd really like to avoid having to switch them all to babel's markup if at all possible.
    – user242047
    Feb 27, 2021 at 21:36
  • Babel has a \babeltags command that adds support for Polyglossia's text-selection commands, e.g. \textchinese. Also, Babel in LuaLaTeX can auto-detect what script you type in, so you might not need to tag languages at all.
    – Davislor
    Feb 27, 2021 at 22:33

1 Answer 1

1

If you add \tracinglostchars=2 to your preamble (or search the .log file), you’ll see the warning message,

Missing character: There is no 经 (U+7ECF)
in font file:HaranoAjiMincho-Regular.otf:jfm=ujis!

This comes from trying to use polyglossia commands with luatexja-fontspec. You wanted to set \chinesefont to UMing. However, lualatex-ja does not use \chinesefont, and you don’t tag the text as Chinese for Polyglossia. So, you get the default font from luatexja-fontspec. This is a Japanese font, so it contains only those Chinese characters that happen to share codepoints with kanji.

There are multiple ways to resolve this. If you want to use luatexja-fontspec, you should use its commands to select the CJK font, \setmainjfont, \newjfontfamily, etc. Also set an English text if you don’t want a package overriding the defaults.

Your TeX installation should also be able to find any font in a subdirectory of \usr\share\fonts\ without a Path= argument. I recommend against putting an absolute Path= in your document, since this will give you a document that will not compile on any other computer. Also, there are multiple font faces in uming.ttc, and you should specify which you want.

\documentclass[12pt,a4paper,oneside]{scrbook}
\tracinglostchars=2
\usepackage[match]{luatexja-fontspec}
\usepackage{polyglossia}
\setdefaultlanguage[variant=american]{english}
\usepackage{csquotes}
%\setotherlanguage{chinese}
\usepackage{xstring}

\defaultfontfeatures{ Ligatures=TeX,
                      Scale=MatchUppercase }

\setmainfont{Latin Modern Roman}[Scale=1.0]
\setmainjfont{AR PL UMing TW}[Renderer=HarfBuzz]

\begin{document}

The common transliteration of 易经 is {\enquote{I Ching,}} 
following the now-obsolete Wade-Giles system: modern Romanization 
of almost all modern Chinese texts follows the Hanyu Pinyin standard used here. 
See [huang].

\end{document}

Latin Modern Roman / UMing TW sample

To use ctex rather than luatexja-fontspec, use its commands to set the CJK fonts, i.e. \newCJKmainfont. It doesn’t play well with csquotes, so you might be forced to \DeclareQuoteStyle.

To stick with polyglossia and use \chinesefont, you would want to add language tagging, e.g. \textchinese{易经}. In XeLaTeX, you could configure ucharclasses to automatically tag Chinese characters as Chinese for you.

Finally, you could use babel. It does not support all the features of ctex or luatexja, but it suffices to insert words and short phrases, written horizontally. Unlike luatexja or ctex, it supports multiple ideographic writing systems in the same document.

You mention in the comments that you have a lot of text already tagged for polyglossia and dread changing it. You can configure babel to support polyglossia user commands, such as \textenglish, and also to auto-detect which script you’re typing in so you don’t need to tag many languages at all.

\documentclass[12pt,a4paper,oneside]{scrbook}
\tracinglostchars=2
\usepackage[english]{babel}
\usepackage{fontspec}
\usepackage{csquotes}
%\setotherlanguage{chinese}
\usepackage{xstring}

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

\defaultfontfeatures{ Ligatures=TeX,
                      Scale=MatchUppercase }

\babelfont{rm}
          [Ligatures=Common, Scale=1.0]{Latin Modern Roman}
\babelfont[chinese]{rm}
          [Renderer=HarfBuzz]{AR PL Uming TW}

% Enable \textenglish, \begin{english}, etc.
\babeltags{english=english}
\babeltags{chinese=chinese}

\begin{document}

The common transliteration of 易经 is {\enquote{I Ching,}} 
following the now-obsolete Wade-Giles system: modern Romanization 
of almost all modern Chinese texts follows the Hanyu Pinyin standard used here. 
See [huang].

\end{document}

Latin Modern Roman / UMing TW sample

1
  • Thank you for the tips! I dropped the paths from those font specifications (though that does seem to make compilation take longer), and added the "j" in the middle. Now it reads \newjfontfamily\chinesefont{Noto Serif CJK TC} and appears to work fine when I enclose Chinese characters with \textchinese{}. Since Polyglossia supports all the other languages I use, I enclose all the rest with \begin{language}****\end{language} environments. One other question: Can you code languages in section titles? It doesn't seem to work (ie, \chapter{\begin{german}Hörspiel\end{german}} fails).
    – user242047
    Feb 28, 2021 at 9:13

You must log in to answer this question.

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