3

I've noticed that Babel's bidi support is gradually improving, and this means that I'm keen to see when I can move over from XeTeX to LuaLaTeX (mostly because of the extra microtype features it will enable).

Here's an example I'm trying to compile:

\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}

What I get is the following, which suggests that I've done something wrong loading Skolar PE as the main font, but also fails to typeset the Hebrew text. The English text is correctly typset, and correctly uses Skolar PE as its font. It's just the Hebrew text that's left out (see attached 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).

Example output

  • Try commenting out lines 2–4 of your example; they’re at least useless with \babelfont, and the example then works for me (well, if I substitute SBL Hebrew, since I don’t have TaameyDavidCLM installed). – Thérèse Jun 1 '18 at 21:19
  • 1
    See p. 24 of the babel manual, at the paragraph beginning: “WARNING: Do not use \setxxxxfont and \babelfont at the same time.” That’s why you need to comment out lines 2–4 of your example. – Thérèse Jun 1 '18 at 21:51
  • 1
6

You're nearly there.

As pointed out in the comments, you don't use the general fontspec commands (\setmainfont, \newfontfamily\hebrewfont{}). Instead babel has its own way of specifying fonts. See §1.14 of the babel manual. You don't even have to directly load fontspec.

I also like to use \babelprovide for all languages and load babel using \usepackage[nil,bidi=basic]{babel}

MWE

\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}

enter image description here

  • Perfect! I'd read that bit of the manual but for some reason didn't put things together - I guess still thinking in a XeTeX world :-) Thank you for the quick and perfect response. – Lyndon Drake Jun 2 '18 at 9:25
  • Out of curiosity, is your preference LuaLaTeX + Babel, or XeTeX + Polyglossia? – Lyndon Drake Jun 2 '18 at 9:25
  • @LyndonDrake, it depends on how complex your RTL requirements are. If your document is mainly LTR, with the occasional RTL word or paragraph, then I now prefer babel (this is because bidi patches a lot of packages and can be a pain to get load order right and polyglossia is a pain to use with biblatex). But if you need complex layout you are probably still better off with the bidi package. – David Purton Jun 2 '18 at 9:40
  • that's helpful. I'll extend my example a bit and see how it goes. I have a fair bit of RTL stuff mixed in, including biblatex citations and RTL text in tables. I'll see how it goes now you've got me up and running with the basics. – Lyndon Drake Jun 2 '18 at 18:20
  • Hmm, no Syriac support is the first little obstacle… I figure I could help get that in place for babel though – Lyndon Drake Jun 2 '18 at 21:15
0

I can offer you an alternative to enable Hebrew in LaTeX using XeLaTeX and Polyglossia package. Use the following header:

% 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.
% ============================================================ %

and compile your document using the XeLaTeX engine.

  • The O.P. has been using xetex; the question is how to work with Hebrew in luatex. – Thérèse Jun 1 '18 at 21:43
  • Thanks but I can get that working - it's the LuaLaTeX version that's been my problem – Lyndon Drake Jun 2 '18 at 9:23

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.