UPDATE:
I've managed to produce something that is aesthetically correct, however with a lot of "hardcoding" and trial and error to manually measure my spaces. Not to mention that I have to write my equation "backwards" (e.g. "^2 b" instead of "b^2", and "0 = s" instead of "s = 0"). Is there a cleaner and more automatic way to do this ? The example then its minimal code follows:
\documentclass{article}
\usepackage[leqno]{amsmath}
\usepackage{graphicx}
\newcommand{\asqrt}[1]{\reflectbox{\ensuremath{\sqrt{\reflectbox{\ensuremath{#1}}}}}}
\newcommand{\asum}[3]{\reflectbox{\ensuremath{\displaystyle\sum\limits_{\reflectbox{\ensuremath{#1}}}^{\reflectbox{\ensuremath{#2}}} \reflectbox{ \ensuremath{#3} }}}}
\usepackage{polyglossia}
\setdefaultlanguage[calendar=gregorian]{arabic} % from polyglossia
\setmainfont[Script=Arabic,Scale=1.8,Mapping=arabicdigits]{Scheherazade}
\begin{document}
\begin{equation}
\asqrt{\frac{ ^{\raisebox{3pt}{\mbox{\tiny 2}}}\mbox{ف} } {\mbox{ب} \mbox{4}}}
\end{equation}
\begin{equation}
\asum{\mbox{\scriptsize 0 = س}}{\hspace{-9pt} \scriptsize \infty}{ ^{\mbox{\small 2}} \mbox{س}}
\end{equation}
\end{document}
Original question:
I am using XeLaTeX along with polyglossia package to typeset a mathematical article in Arabic. It is working very well for text but not for math.
The text is of course set Right-to-Left. However this is not the case for math, which is by default typeset the other way around. Unfortunately, this is not the only problem with it; I do as a matter of fact, need a "mirrored" version of the integration and summation symbols, and square roots.
1) Is there a ready package for that (I did search but didn't find any) ?
2) Is it possible to build such a package without losing existing features like the align environment of amsmath, or I will also have to re-implement that ?
In particular I wondering how bad is my situation if I try to approach implementing a complete solution for RTL math for Arabic.
EDIT: I know there is the question How to typeset an Arabic paper with the equations in the usual Latin in Latex? but it is talking about Latin equation, not Arabic equations.
EDIT 2:
I can try some tricks like mirrorbox (like this \vec{x} but with arrow from right to left?) but still it doesn't work correctly.
There is several problems:
- If I do not put the Arabic characters inside a box (mbox) they do not appear nor reserve a vertical space at all.
- When using the "power" operator "^", I have to put the power before the base. Instead of x^2, I have to write it like ^2 x. However even so, it doesn't look raised because the size of the power mbox wasn't reduced (restricted space problem, it does look raised in the second example).
- Reversed order for numbers and characters. In the denominator of the attached photo, it should appear as "4 b" but rather rendered as "b 4". To render it right I have to reverse the order in my source.
All these reversals will make the source incomprehensible for complex equations.
The example:
\asqrt{ \frac{ ^{\mbox{2}} \mbox{ف} } { \mbox{4 ب} } }
Where \asqrt is defined as :
\usepackage{graphicx}
\newcommand{\asqrt}[1]{\reflectbox{\ensuremath{\sqrt{\reflectbox{\ensuremath{#1}}}}}}
EDIT 3:
It gets hopeless with something like summation. The assignment below the summation should be reversed. Moreover, the need to use mbox makes the proportions very bad as well.
\newcommand{\asum}[3]{\reflectbox{\ensuremath{\sum\limits_{\reflectbox{\ensuremath{#1}}}^{\reflectbox{\ensuremath{#2}}} \reflectbox{ \ensuremath{#3} }}}}
\asum{\mbox{س = 0}}{\infty}{^{\mbox{2}} \mbox{س}}