3

I cannot figure out how babel works for truely multilingual texts. Need at least the following, of which so far German, English, Russian and Greek seem to work, while Korean, Chinese and Arabic do not. I am running XeLaTeX.

\documentclass[a4paper, twoside, ngerman]{book}

\usepackage{fontspec}
\setromanfont{CMU Serif}
\setsansfont{CMU Sans Serif}
\setmonofont{CMU Typewriter Text}

\newfontfamily\arabicfont[Script=Arabic]{Arial Unicode MS}
\newcommand\textarabic[1]{{\arabicfont #1}}
\newfontfamily\koreanfont{UnGungseo}
\newcommand\textkorean[1]{{\koreanfont #1}}

\newfontfamily\chinesefont{FandolSong}
\newcommand\textchinese[1]{{\chinesefont #1}}

\usepackage[bidi=default]{babel}
    \babelprovide[main, import=de]{ngerman}
    \babelprovide[import]{russian}
    \babelprovide[import]{korean}
    \babelprovide[import]{chinese-traditional}
    \babelprovide[import]{arabic}
    \babelprovide[import]{greek}

\begin{document}
    deutsch \foreignlanguage{russian}{Видео урок по живописи маслом} deutsch \textkorean{미술부화실} deutsch
    \textchinese{墨子} deutsch deutsch \foreignlanguage{greek}{πόλεις} deutsch \textarabic{أبو علي الحسن بن الهيثم} deutsch
\end{document} 

1
  • Let babel set up and switch the fonts with \babelfont. You may also want \babeltags. See the manual for details. Also, if there is an ldf file, which is loaded as class or package option, use it, except if for some reason you don't like it. As you are with XeTeX, consider bidi=bidi-l instead of `bidi=default', but this depends largely on the document contents. Oct 25, 2019 at 16:43

2 Answers 2

1

IMHO you need to load other fonts and then locally switch font. I based my answer below on Typesetting arabic with LuaLaTeX (arabic), How to use Chinese with lualatex? (chinese) and Korean Characters Not Working (Korean). Compile with lualatex

\documentclass[a4paper, twoside, ngerman]{book}

\usepackage{fontspec}
\setromanfont{CMU Serif}
\setsansfont{CMU Sans Serif}
\setmonofont{CMU Typewriter Text}

\newfontfamily\arabicfont[Script=Arabic]{Arial Unicode MS}
\newcommand{\textarabic}[1]     % Arabic inside LTR
    {\foreignlanguage{arabic}{{\arabicfont #1}}}

\newfontfamily\koreanfont{UnGungseo}
\newcommand\textkorean[1]{{\koreanfont #1}}

\newfontfamily\chinesefont{FandolSong}
\newcommand\textchinese[1]{{\chinesefont #1}}

\usepackage[bidi=default]{babel}
    \babelprovide[main, import=de]{ngerman}
    \babelprovide[import]{russian}
    \babelprovide[import]{korean}
    \babelprovide[import]{chinese-traditional}
    \babelprovide[import]{arabic}
    \babelprovide[import]{greek}

\begin{document}
    deutsch \foreignlanguage{russian}{Видео урок по живописи маслом} deutsch \textkorean{미술부화실} deutsch 
    \textchinese{墨子} deutsch \textarabic{أبو علي الحسن بن الهيثم} deutsch \foreignlanguage{greek}{πόλεις} deutsch
\end{document} 
11
  • ! Undefined control sequence. <argument> \bgroup \textdir TRT\arabicfont أبو علي الحسن بن الهيثم\egroup l.28 ...utsch \textarabic{أبو علي الحسن بن الهيثم} deutsch \foreignlanguage{... ? X No pages of output. Transcript written on mwe.log. _____________________________________________________________________ XeLaTeX Compilation Report (Pages: 0) Errors: 1 Warnings: 0 Bad Boxes: 0
    – Erik Itter
    Oct 25, 2019 at 11:48
  • can you try to replace "\bgroup\textdir TRT\arabicfont #1\egroup" by "\arabicfont #1"
    – ebcontrol
    Oct 25, 2019 at 12:11
  • the code edited does the characters, but I am pretty sure Arabic is not right-to-left. I am also a bit irritated because of the multiple direct fontspec calls. From the babel documentation I get the impression this should look different
    – Erik Itter
    Oct 25, 2019 at 12:35
  • looks good, just the doubts about the direct fontspec calls, but works, so thx.
    – Erik Itter
    Oct 25, 2019 at 12:47
  • 1
    @ErikItter If you have current babel, doing it this way probably isn't the best idea, as you say. Use of Script etc. is positively discouraged.
    – cfr
    Oct 25, 2019 at 13:00
3

Here is how to do it, with some explanations:

\documentclass[a4paper, twoside, russian, ngerman]{book}

% As there is very good support for both Russian and German with 'ldf'
% files, load them as class options. The last one is the main language.

\usepackage[bidi=default]{babel}

% Depending on the contents you may prefer bidi=bidi-l.

% Now the rest of languages. It is worth noting that 'import' is
% not always required if you need neither captions nor dates, just
% short texts.

\babelprovide[import]{korean}
\babelprovide[import]{chinese-traditional}
\babelprovide[import]{arabic}
\babelprovide[import]{greek}

% Set fonts up. As CMU Serif contains Greek letters, there is no need
% for an explicit setting. 

\babelfont{rm}{CMU Serif}

\babelfont[arabic]{rm}{Arial Unicode MS}
\babelfont[korean]{rm}{UnGungseo}
\babelfont[chinese-traditional]{rm}{FandolSong}

\babelfont{sf}{CMU Sans Serif}

\babelfont{tt}{CMU Typewriter Text}

% Create language macros: \textkorean, \textchinese, \textarab. Note
% I'm not using 'arabic' but 'arab' because \babeltags tries to define
% \arabic, which is already defined. This should be fixed somehow in
% babel.

\babeltags{
  korean=korean,
  chinese=chinese-traditional,
  arab=arabic} 

\begin{document}

    deutsch \foreignlanguage{russian}{Видео урок по живописи маслом} deutsch \textkorean{미술부화실} deutsch 
    \textchinese{墨子} deutsch \textarab{أبو علي الحسن بن الهيثم} deutsch \foreignlanguage{greek}{πόλεις} deutsch

\end{document} 

You must log in to answer this question.

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