14

I am compiling the following MWE using XeLatex within TeXnicCenter and get a garbled equation number:

\documentclass{article}
\usepackage{amsmath}
\usepackage{polyglossia}
\setmainlanguage{hebrew}
\newfontfamily{\hebrewfont}{Arial}

\begin{document}
\begin{equation}\label{eq:1}
2+2=4.
\end{equation}
\end{document} 

enter image description here

What is going on here?

11
  • Not a solution but a comment: I've tried to compile your MWE under LuaLaTeX (MacTeX2013), and apart from a warning message that can be overridden by hitting "r" (for "run"), the MWE seems to compile correctly -- specifically, the equation number is typeset as "(1)".
    – Mico
    Oct 29, 2013 at 6:48
  • 3
    Bad interaction with amsmath, I'm afraid, although bidi and amsmath should be compatible.
    – egreg
    Oct 29, 2013 at 7:32
  • @Mico Yes, you get a PDF with that procedure, but tons of errors. The parentheses come out “correctly” just because all right to left is suppressed because of the errors and of incompatible packages.
    – egreg
    Oct 29, 2013 at 7:37
  • @egreg But I am not including bidi explicitly - does it get loaded by another package or something? And what can you suggest in practical terms to remedy this? Thanks a mil! Oct 29, 2013 at 9:45
  • @egreg Could it be somehow a font thing? Oct 29, 2013 at 9:45

2 Answers 2

7

The problem is caused the label printing macro in amsmath. This uses \@@italiccorr to apply an italic correction before the closing brace, and in this hebrew set-up that changes the character ordering. As the effect of this correction is small anyway, you could remove it in your document. You also need to change \maketag@@@ in order that \eqref works correctly:

Sample output

\documentclass{article}

\usepackage{amsmath}

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

\makeatletter
\def\maketag@@@#1{\hbox{\m@th\normalfont\LRE{#1}}}
\def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip)}}
\makeatother

\begin{document}
\begin{equation}\label{eq:1}
2+2=4.
\end{equation}

\eqref{eq:1}

\end{document}

For comparison the original definition was

\def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}} 
1
  • It seems that in the current version \def\maketag@@@#1{\hbox{\m@th\normalfont\LRE{#1}}} is not required any more. Sep 18, 2019 at 7:30
8

@Andrew Swan's answer breaks bidi package's behaviour (see file amsmath-bidi-xetex.def). The right answer is to pass Script=Hebrew to your font:

\newfontfamily\hebrewfont[Script=Hebrew]{Arial}
3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .