0

I have a document that needs some (mostly inline like names and terms) Chinese, Korean, Arabic and several European languages within a German document.

I am using the standard book class with XeLaTeX, xeCJK and polyglossia. Korean however right now does not work while Chines I can just type inline without anything (the .tex is utf-8 and the Editor works with Unicode). It seems as if I would set the main language if I needed only Korean by what I found in means of tutorials. But the suggested fonts are Korean fonts and not Chinese as well. How do I set this up? Including the fragment that configures my languages so far:

\usepackage[xindy={language=german,codepage=duden-utf8},
    nonumberlist,
    toc,
    nopostdot,
    style=altlist,
    nogroupskip
    ]{glossaries}
    \GlsSetXdyCodePage{duden-utf8}
\apptocmd{\thebibliography}{\raggedright}{}{}

\usepackage{xeCJK}
\usepackage[babelshorthands]{polyglossia}
\newfontfamily{\greekfont}{Calibri}[
Script=Greek,
NFSSFamily=liberationserif,
]
\newfontfamily{\greekfontsf}{Calibri}[
Script=Greek,
NFSSFamily=liberationsans,
]
\newfontfamily\arabicfont[Script=Arabic]{Amiri}%
\newfontfamily\arabicfonttt[Script=Arabic,Scale=.75]{DejaVu Sans Mono}
\newfontfamily\farsifont[Script=Arabic,Scale=1.1,WordSpace=2]{Adobe Arabic}
\newfontfamily\mySymbolsFont{Segoe UI Symbol}
\setdefaultlanguage[spelling=new]{german}
\setotherlanguage[variant=ancient]{greek}
\setotherlanguage[numerals=western]{arabic}
\setotherlanguage{farsi}

I started just with the fragment hoping someone just has a good understanding and can point out how to do it in order not to have to strip it out of a 12000 line document. Should that not hapen I'll create the MWE of course.

  • 1
    One way to do this is with babel, although I don’t know if that’s a good solution for you. If you’re using unified CJK characters that need to be displayed differently within the same document, there’s no way around language-tagging. – Davislor May 23 at 0:08
  • 1
    This doesn’t seem to be an actual MCVE, which makes it a bit harder to tell what you want. – Davislor May 23 at 0:13
2

It’s possible to do this with babel. This makes you tag your languages, but if you’re mixing in bidirectional scripts and unified CJK characters that need to be displayed differently, there’s no way around that.

The following worked for me in XeLaTeX:

\documentclass{article}
% To set the width within the limits of an image on TeX.SX:
\usepackage[paperwidth=11cm]{geometry}
\usepackage[bidi=default]{babel}
\usepackage{fontspec}

% There are variants for German orthographic reforms:
\babelprovide[main, import=de]{german}
\babelprovide[import]{korean}
\babelprovide[import]{arabic}
\babelprovide[import]{chinese-simplified}

% Versions of babel prior to TeX Live 2019 had a bug in \babelfont: it
% ignored all default font features.  On those versions, you will need
% to specify Scale and Ligatures as options to each font below.
\defaultfontfeatures{ Scale=MatchLowercase, Ligatures = TeX }
\babelfont{rm}[Scale=1.0, Ligatures=Common, Language=Default]{Noto Serif}
\babelfont{sf}[Language=Default]{Noto Sans}
\babelfont[arabic]{rm}[Contextuals={WordInitial,WordFinal,Inner}, Language=Default]{Noto Sans Arabic}
\babelfont[arabic]{sf}[Contextuals={WordInitial,WordFinal,Inner}, Language=Default]{Noto Sans Arabic}
\babelfont[chinese-simplified]{rm}[Ligatures={Common,Rare}]{Noto Serif CJK SC}
\babelfont[chinese-simplified]{sf}[Ligatures={Common,Rare}]{Noto Sans CJK SC}
\babelfont[korean]{rm}[Ligatures={Common,Rare}]{Noto Serif CJK KR}
\babelfont[korean]{sf}[Ligatures={Common,Rare}]{Noto Sans CJK KR}

\begin{document}
Deutsch
\foreignlanguage{arabic}{اللغة العربية}
\foreignlanguage{chinese-simplified}{简化字}
\foreignlanguage{korean}{한국어}
\end{document}

Noto font family sample

Here, I use the Noto family of fonts, which covers a large number of languages in both serif and sans-serif. You can substitute the fonts of your choice. The otfinfo -f program is useful to see which OpenType features a given font offers. You can also adjust the settings if you want German hyphenated according to newer rules, or fewer contextual swashes in Arabic, etc.

  • Thanks for the alternative. I'll try to translate that to polyglossia now assuming with XeLaTeX I should stick to that. If that is correct it must be possible to express what you have (should be straight forward), otherwise I'll try to indeed switch back using yours directly. Thanks a lot. – Erik Itter May 25 at 11:13
  • seems polyglossia turns out to have become a dead end. will move back to babel and adopt your solution, thanks. – Erik Itter May 25 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.