我听说过XeTeX 支持 unicode,但我的徒劳尝试却没有任何结果。
\documentclass[12pt]{article}
\begin{document}
א בְּרֵאשִׁית, בָּרָא אֱלֹהִים, אֵת הַשָּׁמַיִם, וְאֵת הָאָרֶץ.
\end{document}
然后:
$ 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.
我想对中文、日语、韩语、阿姆哈拉语、亚美尼亚语、格鲁吉亚语、西里尔语、希腊语、藏语、阿拉伯语等进行此操作。基本上任何 Noto 字体。如何获得 Noto 字体工作的基本示例?
答案1
我假设您想要一个以英语为主的文档,其中包含其他脚本和语言。这是我的解决方案。我使用 LuaLaTeX 和fontspec
,babel
并为每个脚本定义字体。这很好,因为您可以在代码中直接输入阿拉伯语、希伯来语或天城文,而无需任何命令,它就会正确显示。如果您将从右到左和从左到右的系统混合使用,则有一些技巧,有关详细信息,请参阅下面的示例,我从 Overleaf babel 教程中获取了一些示例。
\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}