2

I found some threads in tex.stackexchange about the possibility of writing in Hebrew with Latex (what, however, I already made with fontspec and polyglossia). The answers are an alternative: either fontspec + polyglossia or babel + utf8x. Now, referring to this problem (Xetex support for .otf features), one finds oneself consequently in the (unlikely?) situation of using babel with fontspec. Is it possible to write very short text or single words in Hebrew in this last situation? Or are they incompatible?

Adding a MWE

\documentclass[a4paper]{article}
\usepackage{fontspec}
\usepackage[hebrew,greek,italian]{babel}
\languageattribute{greek}{ancient}
\babelfont[greek,italian]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle}]{Garamond Premier Pro}
\babelfont[hebrew]{rm}[Ligatures=TeX]{Ezra SIL SR}
%\babelfont[italian]{rm}[Language=Default,Ligatures=TeX,Numbers={Proportional,OldStyle}]{<nome_font>}
%\babelfont[english]{rm}[Language=English,Ligatures=TeX,Numbers={Proportional,OldStyle}]{<nome_font>}
%\babelfont{rm}[Ligatures=TeX]{Ezra SIL SR}

\begin{document }
Dopo il passo ove Dio porta a termine l'opera, è collocata una sezione di fonte
jahvista, così chiamata dal nome usato per indicare Dio, anche se qui, precisamente,
vengono usati entrambi i nomi: infatti la denominazione attribuita alla divinità
nel versetto 2,4b suona \selectlanguage{hebrew}אֱלֹהִים יְהוָה \selectlanguage{italian}
(\emph{jahvè 'elohim}, tradotto diffusamente come «il Signore Dio»\footnote{I
Settanta rendono l'espressione con \selectlanguage{greek}κύριος ὀ ϑεός
\selectlanguage{italian} e la Vulgata con \emph{Dominus Deus}.}), poiché
l'originaria fonte jahvista è stata fusa a quella elohista nella redazione
sacerdotale, che mantiene il nome di Jahvé, ma aggiunge il proprio e cioè 'Elohim.
\end{document}

And this is output:

samiel@darkstar:~$ xelatex text.tex 
This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(./text.tex
LaTeX2e <2018-12-01>
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2018/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/local/texlive/2018/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def)))
(/usr/local/texlive/2018/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/tuenc.def))
(/usr/local/texlive/2018/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/local/texlive/2018/texmf-dist/tex/generic/babel/babel.sty
(/usr/local/texlive/2018/texmf-dist/tex/generic/babel/switch.def)
(/usr/local/texlive/2018/texmf-dist/tex/generic/babel-hebrew/rlbabel.def)
(/usr/local/texlive/2018/texmf-dist/tex/generic/babel-hebrew/hebrew.ldf
(/usr/local/texlive/2018/texmf-dist/tex/generic/babel/babel.def
(/usr/local/texlive/2018/texmf-dist/tex/generic/babel/xebabel.def
(/usr/local/texlive/2018/texmf-dist/tex/generic/babel/txtbabel.def)))

Package babel Warning: No hyphenation patterns were preloaded for
(babel)                the language `Hebrew' into the format.
(babel)                Please, configure your TeX system to add them and
(babel)                rebuild the format. Now I will use the patterns
(babel)                preloaded for english instead on input line 57.

) (/usr/local/texlive/2018/texmf-dist/tex/generic/babel-greek/greek.ldf
(/usr/local/texlive/2018/texmf-dist/tex/latex/greek-fontenc/greek-euenc.def
(/usr/local/texlive/2018/texmf-dist/tex/latex/greek-fontenc/greek-fontenc.def))
) (/usr/local/texlive/2018/texmf-dist/tex/generic/babel-italian/italian.ldf))
(/usr/local/texlive/2018/texmf-dist/tex/generic/babel-hebrew/lheenc.def)
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/inputenc.sty

! Package inputenc Error: inputenc is not designed for xetex or luatex.
(inputenc)                only UTF-8 supported.

See the inputenc package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.165 \endinput

SECOND VERSION

Following your direction, I tried this code:

\documentclass{article}
\usepackage{fontspec}
\usepackage[bidi=default]{babel}
\babelprovide[import=it,main]{italian}
\babelprovide[import=el]{greek}
\babelprovide[import=he]{hebrew}
\babelfont[italian]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle}]{Garamond Premier Pro}
\babelfont[greek]{rm}[Ligatures=TeX]{Garamond Premier Pro}
\babelfont[hebrew]{rm}[Ligatures=TeX]{Ezra SIL SR}

\begin{document}

Dopo il passo ove Dio porta a termine l'opera, è collocata una sezione di fonte
jahvista, così chiamata dal nome usato per indicare Dio, anche se qui, precisamente,
vengono usati entrambi i nomi: infatti la denominazione attribuita alla divinità
nel versetto 2,4b suona \selectlanguage{hebrew}אֱלֹהִים יְהוָה \selectlanguage{italian}
(\emph{jahvè 'elohim}, tradotto diffusamente come «il Signore Dio»\footnote{I
Settanta rendono l'espressione con \selectlanguage{greek}κύριος ὀ ϑεός
\selectlanguage{italian} e la Vulgata con \emph{Dominus Deus}.}), poiché
l'originaria fonte jahvista è stata fusa a quella elohista nella redazione
sacerdotale, che mantiene il nome di Jahvé, ma aggiunge il proprio e cioè 'Elohim.

\end{document}

However, if I compile with XeTeX I receive this warning:

! Package babel Error: Multiple bidi settings inside a group

and compilation fails. On the contrary, if I compile with LuaTeX all seems to work fine. All's well that ends well for I have my pdf, but is this different behavior between XeTeX and LuaTeX normal?

  • you can use babel with xelatex/fontspec have you tried and had issues? But your question is rather unclear the font handling is the same whether you use polyglossia or babel, either way you would access fonts via fontspec. – David Carlisle Jan 7 at 1:30
  • See tex.stackexchange.com/a/434568/87678 (babel really needs lualatex for best outcomes with RTL languages though, but you can do really cool things now. Look through all the bidi stuff in the babel manual.) – David Purton Jan 7 at 2:13
  • This answer might also prove useful now I've seen your MWE: tex.stackexchange.com/a/355429/87678 – David Purton Jan 7 at 3:25
  • @DavidPurton Thanks for pointing this out. I'll delete my other comment. Weirdly the gloss-hebrew.ldf file has a warning that says LuaTeX is not supported though. I assume this is ignorable now? – Alan Munn Jan 7 at 4:56
  • @AlanMunn, the new way of doing RTL languages with babel (with xelatex and lualatex) does not use ldf files. Instead everything is defined in babel-he.ini and included using the \babelprovide command. In my view trying to use Hebrew with pdflatex is not worth the pain. – David Purton Jan 7 at 6:00
3

For inline foreign languages use \foreignlanguage{hebrew}{…} rather than \selectlanguage{hebrew} which is intended for new paragraphs.

bidi under xelatex with babel is not as robust as with lualatex. I would use lualatex unless you really have to use xelatex (e.g., for it's better font shaping, but for Hebrew I've generally been able to get what I want with lualatex.)

I would also use bidi=basic which is more clever than bidi=default. But note that bidi=basic does not work with xelatex.

You can still use \newrobustcmd\lining[1]{{\addfontfeature{Numbers=Lining}#1}}, but \newrobustcmd is define in the etoolbox package which is not loaded by default in your second MWE. You just have to load it explicitly.

MWE

Compile with lualatex. You'll still get reasonable results with xelatex if you use bidi=default rather than bidi=basic.

I used Linux Libertine O instead of Garamond Premier Pro which I do not own.

\documentclass{article}
\usepackage[nil,bidi=basic]{babel}
\babelprovide[import=it,main]{italian}
\babelprovide[import=el]{greek}
\babelprovide[import=he]{hebrew}
\babelfont[italian]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle}]{Linux Libertine O}
\babelfont[greek]{rm}[Ligatures=TeX]{Linux Libertine O}
\babelfont[hebrew]{rm}[Ligatures=TeX]{Ezra SIL SR}

\usepackage{etoolbox}
\newrobustcmd\lining[1]{{\addfontfeature{Numbers=Lining}#1}}

\begin{document}
\null\vfill
Dopo il passo ove Dio porta a termine l'opera, è collocata una sezione di
fonte jahvista, così chiamata dal nome usato per indicare Dio, anche se qui,
precisamente, vengono usati entrambi i nomi: infatti la denominazione
attribuita alla divinità nel versetto 2,4b suona
\foreignlanguage{hebrew}{אֱלֹהִים יְהוָה} (\emph{jahvè 'elohim}, tradotto
diffusamente come «il Signore Dio»\footnote{I Settanta rendono l'espressione
con \foreignlanguage{greek}{κύριος ὀ ϑεός} e la Vulgata con \emph{Dominus
Deus}.}), poiché l'originaria fonte jahvista è stata fusa a quella elohista
nella redazione sacerdotale, che mantiene il nome di Jahvé, ma aggiunge il
proprio e cioè 'Elohim.

0123456789

\lining{0123456789}
\end{document}

output

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.