This is an extension to MathJax (v2.5+), that provides basic Arabic support to MathJax.
The extension so far only supports TeX input with HTML-CSS output. However, support to other input and output jaxes is possible.
It provides the following:
- Flip the Equation and render it the Right-to-left (RTL) way!
- Translate commonly used identifiers and functions.
First you'd like to install and configure MathJax in your page.
Then you'll need to include the arabic.js
as an extension, here's an example configuration:
MathJax.Ajax.config.path["arabic"] = "https://cdn.rawgit.com/Edraak/arabic-mathjax/v1.0/dist";
MathJax.Hub.Config({
extensions: [
"[arabic]/arabic.js"
]
});
The extension relies (sort of) on the Amiri font to render beautifully (kinda).
One way to include the font is to add the following CSS from Google Fonts:
<link href='https://fonts.googleapis.com/css?family=Amiri' rel='stylesheet' type='text/css'>
Also you'd like to set the font as the undefined family. Because of a bug in MathJax, you should stick with a single
font-family e.g. use Amiri
or serif
but not Amiri, serif
.
MathJax.Hub.Config({
'HTML-CSS': {
undefinedFamily: 'Amiri'
}
});
The extension provides the following additional TeX commands to be typeset an Arabic equation:
-
\alwaysar
\alwaysar{EQUATION}
A macro to translate and RTL'ize anEQUATION
, whereEQUATION
can be anything fromx = 1
toe^x=\lim_{n\to\infty}
.Wrap any TeX equation with it, and it should just work.
-
\ar
\ar{EQUATION}
(Recommended) A similar macro to\alwaysar{EQUATION}
, but it only translate and RTL'ize the equation if the page is Arabic.Bellow is an example equation:
\ar{x=1}
The above would render x=1 beautifully in an English page, while it should render س=١ in an Arabic page even more beautifully ( in my opinion :) ).
-
Flip everything (almost) including:
- Parentheses
()
, braces{}
, and brackets[]
- Things that should be flipped like: Integration
∫
, Root√
and SigmaΣ
- Parentheses
-
Doesn't flip the things that should't be flipped, like the following letters: Theta
Θ
, Piπ
, and Epsilonε
-
Translate the basic math functions:
\sin
-->جا
\cos
-->تا
\tan
-->ظا
\cot
-->ظتا
\sec
-->قا
\csc
-->قتا
\log
-->لو
-
Translate
\lim
intoنها
, Although some would preferغــا
, but that's just a preference, may someone can patch it to supportar_IQ
for the Iraqi people! -
Render the Arabic numbers (١, ٢, ٣) instead of (1, 2, 3), which is awesome!
-
The following new commands:
- Circle radius:
\radius
Translates tor
andنق
- Area of circle: (and other stuff)
\Area
Translates toA
andم
- Arabic Zero:
\zero
Renders theصفر
in Arabic while printing normal0
in English. The former is usually preferred by the Arabic Math textbooks.
- Circle radius:
-
Bilingual commands, which prints the first argument on English pages and the second argument on Arabic pages. Useful to to build bilingual equations for strings that the extension provides no explicit support to. Note The first (English) argument is always a TeX input, while the second (Arabic) can be TeX, Text or TeX with Symbols, depending on the command you're using.
- Translate a TeX input
\transx
- Translate a text input
\transt
e.g.\transt{\text{if}}{إذا}
for the Math piecewise equations. - Translate a TeX input with Arabic symbols
\transs
: e.g.\transs{A_b}{أ_ب}
- Translate a TeX input
-
Basic variable and function names translation:
A
-->أ
B
-->ب
C
-->حـ
a
-->ا
b
-->ب
c
-->حـ
d
-->د
e
-->هـ
m
-->م
l
-->ل
n
-->ن
f
-->ق
g
-->حـ
h
-->هـ
k
-->ك
r
-->ر
t
-->ت
x
-->س
y
-->ص
z
-->ع
-
Translation to other identifiers and operators like limits (
\lim
), sine, cosine and tan. -
A very configurable translation utility to provide English/Arabic TeX commands (same command, with language-dependent output).
-
A configurable page language detection (defaults to the
lang
attribute of<html>
tag). -
It is generally configurable, but I haven't documented how to do it!
Additional extensions for Physics and some Chemistry units and symbols exists, however, it is not tested/developed well. If you're curious, you can take a look at the following extensions:
-
phys1.js
: Contains general physics units like Farad and speed of light. Interesting stuff, but haven't had proper testing and usage (yet). -
phys2.js
: Additional advanced physics units that I don't understand as much! -
hacks.js
: A hack to convert the English decimal mark from.
to٫
(Arabic decimal mark, Unicode 0x066b). Although the Arabic decimal mark exists, I'm not sure if it is common enough to include it in the main installation.
Well, just issue a pull request to this repo and ping me (my GitHub username is @OmarIthawi). Even better, grab my docker-based development environment from here so you can have a better development experience:
$ git clone https://github.com/Edraak/arabic-mathjax.git
$ cd arabic-mathjax
$ git clone [email protected]:Edraak/MathJax-third-party-extensions.git extensions
$ git clone [email protected]:mathjax/MathJax mathjax
$ cd mathjax
$ git checkout 2.6.1
$ cd ..
$ git clone [email protected]:Edraak/arabic-extension-static.git static
$ make init
$ docker-compose up
The MIT License
Copyright (c) 2015-2016 The Queen Rania Foundation for Education and Development
- Omar Al-Ithawi [email protected]
Why this plugin exists? Well, I could tell you an interesting story like I wanted to change the world, but frankly we needed it to display Math equations for our Arabic learners at Edraak.org, and therefore I made it.
Well, it does change the world somehow, at the least in the eyes of our learners ^_^