The following LaTeX code is saved in the file ~\test.tex:
\documentclass{article}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\usepackage{polyglossia}
%\setmainlanguage{hebrew}
%\setmainfont{Arial}
\usepackage{showlabels}
\begin{document}
\begin{theorem}\label{mythm}
A house is not a home.
\end{theorem}
\end{document}
When the following commands are executed in the Terminal:
cd ~
xelatex test
a PDF file is generated at the path ~\test.pdf. When opened in a PDF viewer, the file displays as follows:
If now the two commented lines are uncommented, and the xelatex test command is rerun, the execution fails, and the ~\test.log file contains the following snippet:
! Package polyglossia Error: The current latin font Arial(0) does not contain t
he "Hebrew" script!
(polyglossia) Please define \hebrewfont with \newfontfamily comm
and.
See the polyglossia package documentation for explanation.
Type H <return> for immediate help.
...
l.15 \begin{theorem}\label{mythm}
?
! Emergency stop.
...
l.15 \begin{theorem}\label{mythm}
End of file on the terminal!
However, if now the showlabels line is commented, and the xelatex test command is rerun, the execution succeeds, and a new ~/test.pdf file is created. When opened in a PDF viewer, the file displays as follows:
(Note that Hebrew is a right-to-left language.)
Why does the second execution fail? How can the problem be fixed?


babelinstead ofpolyglossia. Some time ago the latter was recommended to use with Lua- or XeLaTeX, and I used it myself. Nowbabelhas caught up with it and seems to be more actively developed and better maintained, as well as providing more options and easier use. This is a personal opinion, but I would still recommend switching to babel. – Michael Fraiman Nov 13 '22 at 19:48