4

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

enter image description here

1 Answer 1

2
+100

Maybe something like this?

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


\XeTeXinterchartokenstate=1
\chardef\CharNormal=0
\chardef\CharBound=255
\newXeTeXintercharclass\CharNumbers
\XeTeXcharclass`0=\CharNumbers
\XeTeXcharclass`1=\CharNumbers
\XeTeXcharclass`2=\CharNumbers
\XeTeXcharclass`3=\CharNumbers
\XeTeXcharclass`4=\CharNumbers
\XeTeXcharclass`5=\CharNumbers
\XeTeXcharclass`6=\CharNumbers
\XeTeXcharclass`7=\CharNumbers
\XeTeXcharclass`8=\CharNumbers
\XeTeXcharclass`9=\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}

Inspired by this answer.

Here is the result...

enter image description here

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:

enter image description here

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.

enter image description here

4
  • 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 ?
    – Salim Bou
    Apr 29, 2016 at 13:40
  • I've updated the answer ;)
    – PieCot
    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.
    – Salim Bou
    Apr 30, 2016 at 17:31
  • Updated for enumerate environment.
    – PieCot
    Apr 30, 2016 at 18:11

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.