5

I am working in XeLaTeX + Memoir, and I have two documents: one typeset in English and another typeset in Arabic. As the two documents are related, I am using the package xr to establish cross-references between the two. My Arabic text is using eastern Arabic (so-called Arabic-Indic) numerals. When xr pulls in the page number of the cross-reference from the Arabic Document into my English Document, the number displayed is an Arabic-Indic ١.

What I would like is for this to be presented instead as a (regular) Arabic number as used in English: 1. Obviously these are two different characters, with different glyphs. The font I am using, Khaled Hosny's excellent Amiri, contains both (though at a later stage, the English text will be typeset in a different Latin font).

Thus, my question is how can I replace/substitute one character (1) for another (١), assuming the font contains both?

Here are the MWE files (for xr to work, you must compile the first one, then the second one, then recompile the first one again):

minimalxr1.tex

\documentclass{memoir}
\usepackage{xr}
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{arabic}

\setromanfont[Mapping=tex-text,Numbers=OldStyle,Ligatures=Common]{Amiri}
\newfontfamily\arabicfont[Script=Arabic,Scale=1.2,WordSpace=1.66]{Amiri}

\externaldocument{minimalxr2}

\begin{document}

This is a test of cross-referencing to this page \pageref{test}.

\end{document}

minimalxr2.tex

\documentclass{memoir}
\usepackage{xr}
\usepackage{polyglossia}
\setmainlanguage[numerals=mashriq]{arabic}
\newfontfamily\arabicfont[Ligatures=TeX,Script=Arabic,Scale=1.2,WordSpace=1.66]{Amiri}

\externaldocument{minimalxr1}

\begin{document}

\begin{Arabic}

هذا أنموذج 
\label{test}

\end{Arabic}

\end{document}
1
  • NB: I have played around with things like catcode definitions which make one character expand into another: but because I am not actually typing in the Arabic ١, but it is rather being pulled in through the XR package, this has no effect. I also tried with \XeTeXinterchartokenstate but wasn't able to get it to work (due most likely to my inexperience).
    – talazem
    Jul 27, 2015 at 17:58

1 Answer 1

5

If you don't need Arabic in minimalxr1.tex, you can use \newunicodechar as follows. Language tests could be added.

minimalxr1.tex

\documentclass{memoir}
\usepackage{xr}
\usepackage{polyglossia}
\usepackage{newunicodechar}
\setmainlanguage{english}
\setotherlanguage{arabic}

\newunicodechar{١}{1}
\newunicodechar{٢}{2}
\newunicodechar{٣}{3}
\newunicodechar{٤}{4}
\newunicodechar{٥}{5}
\newunicodechar{٦}{6}
\newunicodechar{٧}{7}
\newunicodechar{٨}{8}
\newunicodechar{٩}{9}
\newunicodechar{٠}{0}


\setmainfont[Mapping=tex-text,Numbers=OldStyle,Ligatures=Common]{Amiri}
\newfontfamily\arabicfont[Script=Arabic,Scale=1.2,WordSpace=1.66]{Amiri}

\externaldocument{minimalxr2}

\begin{document}

This is a test of cross-referencing to this page \pageref{test}.

Also \pageref{2},
\pageref{3},
\pageref{4},
\pageref{5},
\pageref{6},
\pageref{7},
\pageref{8},
\pageref{9},
\pageref{10}

\end{document}

minimalxr2.tex

\documentclass{memoir}
\usepackage{xr}
\usepackage{polyglossia}
\setmainlanguage[numerals=mashriq]{arabic}
\newfontfamily\arabicfont[Ligatures=TeX,Script=Arabic,Scale=1.2,WordSpace=1.66]{Amiri}

\externaldocument{minimalxr1}

\begin{document}

\begin{Arabic}

هذا أنموذج 
\label{test}

\end{Arabic}

\newpage
x\label{2}

\newpage
x\label{3}

\newpage
x\label{4}

\newpage
x\label{5}

\newpage
x\label{6}

\newpage
x\label{7}

\newpage
x\label{8}

\newpage
x\label{9}

\newpage
x\label{10}

\end{document}

minimalxr1.pdf

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .