# Change numbers format in arabtex

I would get Arabic numbering within arabtex environment defined from arabtex package to write arabic sentences.

If I insert numbers 1,2,3,.... inside arabtex environment I get indian form ١,٢,٣,....

I know I can just type \LR{1,2,3,...},but I would like to get it automatically without inserting it inside \LR every time, also with format of counters like \thepage.

I suspect this has to do with the font nash which define the format of numbers, any suggestion

Update

I use pdflatex to compile my document

MWE

\documentclass[a4paper,12pt]{article}
\usepackage{arabtex}
\usepackage{utf8}

\begin{document}

\setcode{utf8}

\begin{arabtex}
\huge 1 2 3
\end{arabtex}

\end{document}


Result

Maybe something like this?

\documentclass[a4paper,12pt]{article}
\usepackage{arabtex}
\usepackage{utf8}

\XeTeXinterchartokenstate=1
\chardef\CharNormal=0
\chardef\CharBound=255
\newXeTeXintercharclass\CharNumbers
\XeTeXcharclass0=\CharNumbers
\XeTeXcharclass1=\CharNumbers
\XeTeXcharclass2=\CharNumbers
\XeTeXcharclass3=\CharNumbers
\XeTeXcharclass4=\CharNumbers
\XeTeXcharclass5=\CharNumbers
\XeTeXcharclass6=\CharNumbers
\XeTeXcharclass7=\CharNumbers
\XeTeXcharclass8=\CharNumbers
\XeTeXcharclass9=\CharNumbers
\newtoks\TokSetfont
\TokSetfont={\begin{normalfont}}
\XeTeXinterchartoks\CharNormal\CharNumbers=\TokSetfont
\XeTeXinterchartoks\CharBound\CharNumbers=\TokSetfont
\XeTeXinterchartoks\CharNumbers\CharNormal={\end{normalfont}}
\XeTeXinterchartoks\CharNumbers\CharBound={\end{normalfont}}

\begin{document}

\setcode{utf8}

\begin{arabtex}
\huge 1 hello 2 3 345
\end{arabtex}

\end{document}


Here is the result...

## UPDATE WITH PDFLATEX

The following solution is compatible with pdflatex, based on the l3regex package:

\documentclass[a4paper,12pt]{article}
\usepackage{arabtex}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{utf8}
\setcode{utf8}

\usepackage{expl3}
\usepackage{l3regex}
\ExplSyntaxOn
\tl_new:N \l_substituteNumbers_tl
\cs_new:Npn \substituteNumbers #1 {
\tl_set:Nn \l_substituteNumbers_tl {#1}
\regex_replace_all:nnN {[0-9]+} {  \c{LR}\cB {\0 \cE}  } \l_substituteNumbers_tl
\tl_use:N \l_substituteNumbers_tl
}
\ExplSyntaxOff

\begin{document}

\substituteNumbers{%
\begin{arabtex}%
\huge 1 hello 2 3 345
\end{arabtex}%
}%

\end{document}


And this is what you get:

I hope that this solution fix your problem!

## UPDATE 2: Enumeration fixed

\documentclass[a4paper,12pt]{article}
\usepackage{arabtex}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{utf8}
\setcode{utf8}

\usepackage{expl3}
\usepackage{l3regex}
\ExplSyntaxOn
\tl_new:N \l_substituteNumbers_tl
\cs_new:Npn \substituteNumbers #1 {
\tl_set:Nn \l_substituteNumbers_tl {#1}
\regex_replace_all:nnN {[0-9]+} {  \c{LR}\cB {\0 \cE}  } \l_substituteNumbers_tl
\tl_use:N \l_substituteNumbers_tl
}
\ExplSyntaxOff

\renewcommand{\theenumi}{\LR{\arabic{enumi}}}

\begin{document}

\substituteNumbers{%
\begin{arabtex}%
\huge 1 hello 2 3 345

\begin{enumerate}
\item A 1
\item B 2
\item C 3
\item D 4
\item E 5
\end{enumerate}

\end{arabtex}%
}%

\end{document}


In this version, enumerate environment uses arabic numbers, as required by @salim bou. The result of the previous code is shown in the following image.

• Thanks @PieCot your code resolve the problem well with xelatex, but I need to compile my code with pdflatex Is there a possibility for that ? Apr 29, 2016 at 13:40
• I've updated the answer ;) Apr 30, 2016 at 16:54
• How about format of conters like enumi, I still get indian format of numbers inside enumerate environment, sorry because I did not made this clear in my question. I want all apearance of numbers will be on arabic form. Apr 30, 2016 at 17:31
• Updated for enumerate environment. Apr 30, 2016 at 18:11