2

I have heard that XeTeX supports unicode, but in my futile attempts nothing comes about.

\documentclass[12pt]{article}
\begin{document}
א  בְּרֵאשִׁית, בָּרָא אֱלֹהִים, אֵת הַשָּׁמַיִם, וְאֵת הָאָרֶץ.
\end{document}

Then:

$ xetex example.tex
This is XeTeX, Version 3.14159265-2.6-0.999991 (TeX Live 2019) (preloaded format=xetex)
 restricted \write18 enabled.
entering extended mode
(./he.tex
! Undefined control sequence.
l.1 \documentclass
                  [12pt]{article}
? ^D
! Emergency stop.

I would like to do this for Chinese, Japanese, Korean, Amharic, Armenian, Georgian, Cyrillic, Greek, Tibetan, Arabic, etc. Basically any Noto font. How can I get a basic example with Noto font working?

Lance
  • 1,799

1 Answers1

5

I will assume you want a mainly English document with other scripts and languages. Here is my solution. I use LuaLaTeX with fontspec and babel, and I define the font for every script. This is nice because you can just type Arabic, Hebrew, or Devanagari directly in your code without any command, and it will show properly. There are some tricks if you mix right-to-left with left-to-right systems, see the example below for details, I took some examples from the Overleaf babel tutorial.

\documentclass[10pt]{article}
\usepackage{fontspec}
\usepackage{lmodern} % My main font package of the document

\usepackage[american, bidi=basic]{babel} \babelprovide[onchar=ids fonts]{arabic} % Provides character based script identification \babelprovide[onchar=ids fonts]{hebrew} \babelprovide[onchar=ids fonts]{sanskrit-devanagari}

\babelfont[*arabic]{rm}[Language = Default]{Noto Naskh Arabic} % Define fonts \babelfont[*hebrew]{rm}[Language = Default]{Noto Serif Hebrew} \babelfont[*devanagari]{rm}[Renderer=Harfbuzz]{Noto Serif Devanagari}

% For scripts/languages outside the scope babel, I need to define a fontspec command: \newfontfamily\tibetanfont{Noto Serif Tibetan} \newfontfamily\javanesefont{Noto Sans Javanese}

% For CJK, you can use kotex \usepackage{kotex} \setmainhangulfont{Noto Serif CJK KR} % only on Overleaf

\begin{document}

\section{Various scripts and languages:}

Samples:

Simplified Chinese: 汉字:艹草,谢谢。 \textbf{汉字:艹草,谢谢。}

Traditional Chinese: 漢字:艸草,謝謝。 \textbf{漢字:艸草,謝謝。}

Japanese: ありがとうございました \textbf{ありがとうございました }

Korean: 감사합니다 \textbf{감사합니다}

Greek: ευχαριστώ \textbf{ευχαριστώ}

Russian: спасибо \textbf{спасибо}

Hungarian: köszönöm szépen \textbf{köszönöm szépen}

Hindi: \textnormal{धन्यवाद} \textbf{धन्यवाद}

Arabic: شكرا جزيلا \textbf{شكرا جزيلا}

\textnormal Hebrew: תֹהוּ וָבֹהוּ \textbf{תֹהוּ וָבֹהוּ}

Tibetan: {\tibetanfont{ཐུགས་རྗེ་ཆེ་།}} {\textbf{\tibetanfont{ཐུགས་རྗེ་ཆེ་།}}}

Javanese: {\javanesefont{ꦩꦠꦸꦂꦤꦸꦮꦸꦤ꧀}} {\textbf{\javanesefont{ꦩꦠꦸꦂꦤꦸꦮꦸꦤ꧀}}}

\section{Bidirectional scritps}

\subsection{Arabic and Hebrew in English paragraphs, in mixed environments}

ما هو \foreignlanguage{english}{differentiation}? What is ما هو in Arabic? For inline usage, you can use a command \foreignlanguage{hebrew}{תַּבְלִין}, but also works without it תַּבְלִין. Example:

\bigskip \noindent Most Arabic speakers consider the two varieties to be two registers of one language, although the two registers can be referred to in Arabic as فصحى العصر \textit{fuṣḥā l-ʻaṣr} Modern Standard Arabic (MSA) and فصحى التراث \textit{fuṣḥā t-turāth} Classical Arabic (CA). ʿArab={i}.

\bigskip The first line of the Bible is בְּרֵאשִׁית בָּרָא אֱלֹהִים אֵת הַשָּׁמַיִם וְאֵת הָאָרֶץ (Genesis 1:1).

\subsection{Full right-to-left paragraph}

\bigskip \selectlanguage{arabic} مكانة عائلته الاجتماعية مكنته من الدراسة على يد أفضل المدرسين في المغرب العربي. تلقى علم التربية الإسلامية التقليدية، ودرس القرآن الكريم الذي كان يحفظه عن ظهر قلب، واللسانيات العربية، وأساس فهم القرآن، الحديث، الشريعة (القانون) والفقه علم التاريخ.

\selectlanguage{english}

\subsection{The rest} Sanskrit and CJK are no problem, they are left-to-right, just input them directly.

\end{document}

enter image description here