0

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:

No polyglossia, yes labels.

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:

Polyglossia without showlabels

(Note that Hebrew is a right-to-left language.)

Why does the second execution fail? How can the problem be fixed?

Evan Aad
  • 11,066
  • 1
    I think you can try LuaLaTeX with babel instead of polyglossia. Some time ago the latter was recommended to use with Lua- or XeLaTeX, and I used it myself. Now babel has 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

2 Answers2

1

The showkey-label is printed in typewriter and polyglossia errors as the default typewriter font can't handle hebrew. But polyglossia's error message are rather bad here, as the proposed fix doesn't work.

Either use for all three font families a font that can handle hebrew, or define a suitable hebrew fallback (some mix works too):

\documentclass{article}

\usepackage{polyglossia} \setmainlanguage{hebrew} \newfontfamily\hebrewfont{Arial} \newfontfamily\hebrewfonttt{Arial} \newfontfamily\hebrewfontsf{Arial}

\usepackage{showlabels}

\begin{document} abc {\sffamily abc} {\ttfamily abc} \end{document}

or

\documentclass{article}

\usepackage{polyglossia} \setmainlanguage{hebrew} \setmainfont{Arial} \setsansfont{Arial} \setmonofont{Arial}

\usepackage{showlabels}

\begin{document} abc {\sffamily abc} {\ttfamily abc} \end{document}

Or consider to use babel.

Ulrike Fischer
  • 327,261
1

The other possibility is to adjust the font that showlabels is using, to one that evades the problem.

For example:

\usepackage{polyglossia}
\setmainlanguage{hebrew}
\setmainfont{Arial}

\usepackage{showlabels} \renewcommand{\showlabelfont}{\textrm}

This successfully shows the label in the current text font. I expect more imaginative alternatives would work, too.

Norman Gray
  • 7,497
  • 2
  • 25
  • 35