13

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?

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

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)}} 
4

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

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.