[XeTeX] Local changes to mathmode digits

David Carlisle d.p.carlisle at gmail.com
Sun Jan 13 13:29:54 CET 2013


On 12 January 2013 15:58, Nathan Camillo Sidoli <sidoli at waseda.jp> wrote:
> Is there anyway to change the math mode digits for only certain parts of a
> text?
>
> I have some math in Arabic text in a largely English document. I would like
> to change the math mode digits in this parts to use Eastern Arabic digits,
> whereas the rest of the text will use standard Hindu-Arabic digits.
>
> For an entire document, I can use
>
> \usepackage{xepersian-mathsdigitspecarab}
> \setdigitfont[Mapping=arabicdigits]{Arabic Font}
>
> to change the digits, but is there anyway I can just make this active for
> certain parts of the overall document?
>
>
> Thanks,
>
> Nathan
>
>

The packages may have a higher level interface to this, but othewise
you can just (locally) change the mathcode, something like

\documentclass{article}

\usepackage{unicode-math}
\setmathfont{xits-math.otf}


\def\offsetdigits#1{%
\xoffset{#1}0%
\xoffset{#1}1%
\xoffset{#1}2%
\xoffset{#1}3%
\xoffset{#1}4%
\xoffset{#1}5%
\xoffset{#1}6%
\xoffset{#1}7%
\xoffset{#1}8%
\xoffset{#1}9}

\def\xoffset#1#2{%
\XeTeXmathcodenum`#2=\numexpr\XeTeXmathcodenum`#2-`0+#1\relax}

\begin{document}


$a = 123$

{
%ARABIC-INDIC DIGIT ZERO
\offsetdigits{"0660}

$a = 123$

}

{
%EXTENDED ARABIC-INDIC DIGIT ZERO (not in my fonts)
\offsetdigits{"06F0}

$a = 123$

}


$a = 123$

\end{document}


More information about the XeTeX mailing list