3

When I use two different languages like English and Arabic (one is written form left to right and the other is written from right to left), the equation numbers are written in Arabic, e.g. 14, but when I use \ref it returns 41. I tried \textRL, but the format of the number changes from Arabic to English. So I need all numbers in the document to be written in the same format (English or Arabic), any suggestion please? I use this code.

\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage[english,arabic]{babel}
\usepackage[LAE]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
نبين فلتحكم الكلي يما يلي قانون
% here there are equations more than ten

\begin{equation}\label{eq:lyap_tot}
\color{blue}{\boxed{\color{black}u=u_\theta-u_x}}
\end{equation}

figure \ref{lyap_tot} shows ... % here the returned number is written in arabic 
% but from left to right ( the real number is 14 and the retunred number is 41)
\end{document}
  • 2
    Hi and welcome to the site. Can you post a minimal document that shows the problem. It should be a complete document, but with just enough code to show us what you're doing (no extra packages) and shows the problem. See I've just been asked to write a minimal example, what is that?. – Alan Munn Jul 4 '16 at 20:48
  • @AlanMunn add the minimal document that shows the problem – Ahmad Hafez Jul 7 '16 at 16:28
  • From the looks of this document, your main document is in Arabic. Do you want your equation numbers to be in Arabic or English? I would recommend you use XeLaTeX and polyglossia instead. If this is acceptable I can post a solution. – Alan Munn Jul 7 '16 at 17:21
  • @AlanMunn yes the main document is in Arabic, but I need English for scientific expressions. It is acceptable to use XeLateX – Ahmad Hafez Jul 8 '16 at 11:16
4

Here your code with polyglossia which require XeLaTeX engine

  • First you set default language with \setdefaultlanguage[calendar=gregorian,numerals=maghrib]{arabic}, option numerals=maghrib for arabic form of numerals 1, 2, 3, .... in opposite to numerals=machriq for Indian form ٣ ٢ ١ .....
  • Define other languages on your document with \setotherlanguage{english}
  • Define font for arabic script with \newfontfamily\arabicfont[Script=Arabic]{Name_of_font}

Code

\documentclass{article}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{polyglossia}

\setdefaultlanguage[calendar=gregorian,numerals=maghrib]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic]{Amiri}
\newfontfamily\englishfont{Amiri}
\parindent 0pt
\begin{document}
نبين فلتحكم الكلي يما يلي قانون

\setcounter{equation}{13}

\begin{equation}\label{eq:lyap_tot}
\color{blue}{\boxed{\color{black}u=u_\theta-u_x}}
\end{equation}

\begin{english}
equation \ref{eq:lyap_tot} shows .....
\end{english}

المعادلة 
\ref{eq:lyap_tot} 
تبين أن ......

\end{document}

Result

enter image description here

  • Thanks Salim. I was going to post this answer too, but I'm much happier to see it coming from you. :) – Alan Munn Jul 8 '16 at 16:09

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.