我注意到 Babel 对 bidi 的支持正在逐渐改善,这意味着我很想知道什么时候可以从 XeTeX 转移到 LuaLaTeX(主要是因为microtype
它将启用额外的功能)。
这是我正在尝试编译的一个例子:
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Skolar PE}
\newfontfamily\hebrewfont[Script=Hebrew,BoldFont=TaameyDavidCLM-Bold,ItalicFont=TaameyDavidCLM-MediumOblique,BoldItalicFont=TaameyDavidCLM-BoldOblique]{TaameyDavidCLM-Medium}
\usepackage[main=british,bidi=basic]{babel}
\babelprovide[import=he]{hebrew}
\babelfont{rm}{SkolarPE}
\babelfont[hebrew]{rm}{TaameyDavidCLM-Medium}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Fames ac turpis egestas maecenas pharetra convallis. Eleifend donec pretium vulputate sapien nec. Id ornare arcu odio ut sem. Sed adipiscing diam donec adipiscing tristique risus nec. Ut porttitor leo a diam sollicitudin tempor id. Egestas sed tempus urna et pharetra pharetra. Magna eget est lorem ipsum dolor sit amet. Ipsum dolor sit amet consectetur adipiscing elit. Neque volutpat ac tincidunt vitae semper quis lectus nulla. Dui faucibus in ornare quam viverra orci sagittis. Eu sem integer vitae justo eget magna. Tristique senectus et netus et malesuada fames ac. Volutpat blandit aliquam etiam erat velit scelerisque in dictum. At lectus urna duis convallis convallis tellus id interdum velit. Porttitor lacus luctus accumsan tortor posuere. Ut aliquam purus sit amet.
\begin{otherlanguage}{hebrew}
שיר המעלות לשלמה אם יהוה לא יבנה בית שוא עמלו בוניו בו אם יהוה לא ישמר עיר שוא שקד שומר׃
\end{otherlanguage}
\end{document}
我得到的结果是以下结果,这表明我在加载 Skolar PE 作为主字体时做错了什么,但也没有排版希伯来语文本。英文文本排版正确,并且正确地使用 Skolar PE 作为其字体。只是希伯来语文本被遗漏了(见附件 PDF)。
*************************************************
* fontspec warning: "language-not-exist"
*
* Language 'English' not available for font 'SkolarPE' with script 'Latin'.
* 'Default' language used instead.
*************************************************
(./lualatex-hebrew-test.aux
Package babel Warning: The current font is not a standard family:
(babel) SkolarPE:mode=node;script=latn;language=DFLT;+tlig;
(babel) Script and Language are not applied. Consider defining a
(babel) new family with \babelfont. Reported on input line 2.
*************************************************
* fontspec warning: "language-not-exist"
*
* Language 'Hebrew' not available for font 'TaameyDavidCLM-Medium' with script
* 'Hebrew'.
* 'Default' language used instead.
*************************************************
Package babel Warning: The current font is not a standard family:
(babel) SkolarPE:mode=node;script=latn;language=DFLT;+tlig;
(babel) Script and Language are not applied. Consider defining a
(babel) new family with \babelfont. Reported on input line 3.
Package babel Warning: The current font is not a standard family:
(babel) SkolarPE:mode=node;script=latn;language=DFLT;+tlig;
(babel) Script and Language are not applied. Consider defining a
(babel) new family with \babelfont. Reported on input line 4.
)
Package babel Warning: The current font is not a standard family:
(babel) SkolarPE:mode=node;script=latn;language=DFLT;+tlig;
(babel) Script and Language are not applied. Consider defining a
(babel) new family with \babelfont. Reported on input line 26.
[1{/usr/local/texlive/2018/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./lualatex-hebrew-test.aux
Package babel Warning: The current font is not a standard family:
(babel) SkolarPE:mode=node;script=latn;language=DFLT;+tlig;
(babel) Script and Language are not applied. Consider defining a
(babel) new family with \babelfont. Reported on input line 2.
Package babel Warning: The current font is not a standard family:
(babel) SkolarPE:mode=node;script=latn;language=DFLT;+tlig;
(babel) Script and Language are not applied. Consider defining a
(babel) new family with \babelfont. Reported on input line 3.
Package babel Warning: The current font is not a standard family:
(babel) SkolarPE:mode=node;script=latn;language=DFLT;+tlig;
(babel) Script and Language are not applied. Consider defining a
(babel) new family with \babelfont. Reported on input line 4.
))
(see the transcript file for additional information)
426 words of node memory still in use:
4 hlist, 1 vlist, 1 rule, 5 glue, 7 attribute, 49 glue_spec, 5 attribute_lis
t, 1 write nodes
avail lists: 2:37,3:12,4:4,5:66,6:2,7:1085,8:1,9:19,10:3,11:63
</Users/lyndon/Library/Fonts/SkolarPE-Regular.otf>
Output written on lualatex-hebrew-test.pdf (1 page, 7588 bytes).
答案1
您就快完成了。
正如评论中指出的那样,您不使用通用fontspec
命令(\setmainfont
, \newfontfamily\hebrewfont{}
)。而是babel
有自己的指定字体的方式。请参阅babel
手册的§1.14。您甚至不必直接加载fontspec
。
我也喜欢使用\babelprovide
所有语言并使用加载 babel\usepackage[nil,bidi=basic]{babel}
平均能量损失
\documentclass{article}
\usepackage{lipsum}
\usepackage{microtype}
\usepackage[nil,bidi=basic]{babel}
\babelprovide[import=en-GB,main]{british}
\babelprovide[import=he]{hebrew}
\babelfont{rm}[
Ligatures=TeX,
SmallCapsFont={Latin Modern Roman Caps}]%
{Latin Modern Roman}
\babelfont[hebrew]{rm}[
Ligatures = TeX,
ItalicFont = TaameyDavidCLM-MediumOblique,
BoldFont = TaameyDavidCLM-Bold,
BoldItalicFont = TaameyDavidCLM-BoldOblique]%
{TaameyDavidCLM-Medium}
\begin{document}
\lipsum[1]
\begin{otherlanguage}{hebrew}
שיר המעלות לשלמה אם יהוה לא יבנה בית שוא עמלו בוניו בו אם יהוה לא ישמר עיר שוא
שקד שומר׃
\emph{שיר המעלות לשלמה אם יהוה לא יבנה בית שוא עמלו בוניו בו אם יהוה לא ישמר
עיר שוא שקד שומר׃}
\textbf{שיר המעלות לשלמה אם יהוה לא יבנה בית שוא עמלו בוניו בו אם יהוה לא ישמר
עיר שוא שקד שומר׃}
\textbf{\emph{שיר המעלות לשלמה אם יהוה לא יבנה בית שוא עמלו בוניו בו אם יהוה
לא ישמר עיר שוא שקד שומר׃}}
\end{otherlanguage}
\end{document}
答案2
我可以为您提供另一种方法,使用 XeLaTeX 和 Polyglossia 包在 LaTeX 中启用希伯来语。使用以下标题:
% XeLaTeX!
% ============================================================ %
% HEBREW support via polyglossia %
% ============================================================ %
\usepackage{polyglossia}
\defaultfontfeatures{Mapping=tex-text , Scale=MatchLowercase}
\setdefaultlanguage{english}
\setotherlanguage{hebrew}
\newfontfamily\hebrewfont[Script=Hebrew]{Times New Roman}
% fix equation numbering
\makeatletter
\let\mytagform@=\tagform@
\def\tagform@#1{\maketag@@@{\textenglish{(\ignorespaces#1\unskip\
@@italiccorr)}}\hspace{3mm}}
\renewcommand{\eqref}[1]{\textup{\mytagform@{\ref{#1}}}}
\makeatother
% Use \begin{hebrew} block of text \end{hebrew} for paragraphs.
% Use \texthebrew{ } and \textenglish{ } for short texts.
% ============================================================ %
并使用 XeLaTeX 引擎编译您的文档。