[XeTeX] changing font for numbers in math mode?

Ulrike Fischer news3 at nililand.de
Thu Jun 30 11:39:52 CEST 2011


Am Mon, 27 Jun 2011 16:18:30 +0200 schrieb Ernest Adrogué:

> Hi,
> 
> 27/06/11 @ 08:32 (+0100), David Cottenden escriu:
>> Greetings,
>> 
>> I'm not very expert - so don't quiz me overly - but my understanding
>> is that setmathrm changes the maths roman font, whereas by default
>> the maths digits are drawn from the normal maths font. You can
>> change which font the digits are drawn from with:
>> 
>>   \DeclareMathSymbol{0}\mathalpha{operators}{"30}
>>   \DeclareMathSymbol{1}\mathalpha{operators}{"31}
>>   \DeclareMathSymbol{2}\mathalpha{operators}{"32}
>>   \DeclareMathSymbol{3}\mathalpha{operators}{"33}
>>   \DeclareMathSymbol{4}\mathalpha{operators}{"34}
>>   \DeclareMathSymbol{5}\mathalpha{operators}{"35}
>>   \DeclareMathSymbol{6}\mathalpha{operators}{"36}
>>   \DeclareMathSymbol{7}\mathalpha{operators}{"37}
>>   \DeclareMathSymbol{8}\mathalpha{operators}{"38}
>>   \DeclareMathSymbol{9}\mathalpha{operators}{"39}
>> 
>> I've been using this for a year or two to replace Euler digits
>> (which may have merits, but clearly don't match any text digits).
> 
> It doesn't seem to work in my computer.
> 
> The code below gives me different fonts in math and non-math mode
> (fonts are quite similar, but it can be seen Charis SIL is thicker,
> also the "9" is different).

Assuming that you want to change only the numbers:

\documentclass[12pt,a4paper]{article}
\usepackage[charter]{mathdesign}
\usepackage{fontspec}
\setmainfont[Scale=0.95]{Charis SIL}


\normalfont
\makeatletter

\DeclareSymbolFont{Mynumbers}\zf at enc\f at family\mddefault\updefault
\SetSymbolFont{Mynumbers}{bold}\zf at enc\f at family\bfdefault\updefault
\SetSymbolFont{Mynumbers}{normal}\zf at enc\f at family\mddefault\updefault
\DeclareMathSymbol{0}\mathalpha{Mynumbers}{"30}
\DeclareMathSymbol{1}\mathalpha{Mynumbers}{"31}
\DeclareMathSymbol{2}\mathalpha{Mynumbers}{"32}
\DeclareMathSymbol{3}\mathalpha{Mynumbers}{"33}
\DeclareMathSymbol{4}\mathalpha{Mynumbers}{"34}
\DeclareMathSymbol{5}\mathalpha{Mynumbers}{"35}
\DeclareMathSymbol{6}\mathalpha{Mynumbers}{"36}
\DeclareMathSymbol{7}\mathalpha{Mynumbers}{"37}
\DeclareMathSymbol{8}\mathalpha{Mynumbers}{"38}
\DeclareMathSymbol{9}\mathalpha{Mynumbers}{"39}

\makeatother
\begin{document}

\noindent
0123456789 \\
$0123456789$ \\
foo

\mathversion{bold}

$1234$
\end{document}

-- 
Ulrike Fischer 



More information about the XeTeX mailing list