# Equation number enclosing parentheses misplaced with Polyglossia+Hebrew+amsmath

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}
$$\label{eq:1} 2+2=4.$$
\end{document}


What is going on here?

• 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 '13 at 6:48
• Bad interaction with amsmath, I'm afraid, although bidi and amsmath should be compatible. Oct 29 '13 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. Oct 29 '13 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 '13 at 9:45
• @egreg Could it be somehow a font thing? Oct 29 '13 at 9:45

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:

\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}
$$\label{eq:1} 2+2=4.$$

\eqref{eq:1}

\end{document}


For comparison the original definition was

\def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}}

• It seems that in the current version \def\maketag@@@#1{\hbox{\m@th\normalfont\LRE{#1}}} is not required any more. Sep 18 '19 at 7:30

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

• Hello. I have the same problem of parenthesis, well posed here tex.stackexchange.com/questions/210152/… I verified that the macro of Swann solves my problem but I'm afraid that it " breaks bidi package's behaviour" like @Vafa Khaligi said. Now my analogous command '\newfontfamily\arabicfont[Script=Arabic]{Traditional Arabic}' doesn't change anything. A solution ? Nov 2 '14 at 12:54
• I found the solution here tex.stackexchange.com/questions/185987/… Nov 2 '14 at 13:32
• This doesn't always work Nov 30 '17 at 9:58