# Lining *and* oldstyle figures in maths

Here is my problem: I would like, as in some old maths books, use oldstyle figures as coefficients in math formulae – say in display- and textstyle, but lining figures for indices and exponents – say in script- and scriptscriptstyle. I'm not sure this is strictly equivalent, though. I guess that the use of the \mathchoice command would be useful, but I really don't know how to use it.

Does anyone know how to achieve this automatically?

Added: I forgot to say that a solution should work with any math font. It happens that the proposed solution, which works perfectly well with default TeX math fonts doesn't work with MinionPro. Maybe a specific problem of MinionPro?

• My solution works with all math fonts that define \mathnormal and have oldstyle digits in that font. As far as I know, MinionPro is not a math font. Without an example of what you're doing, it's impossible to tell. Sep 10 '13 at 19:42

I wouldn't do it. Old books are not always examples of good typography.

\documentclass{article}

\makeatletter
\def\changedigit#1{%
\begingroup\lccode~=#1\lowercase{\endgroup
\edef~}{{\mathchoice
{\noexpand\mathnormal{\mathchar\the\mathcode#1}}
{\noexpand\mathnormal{\mathchar\the\mathcode#1}}
{\mathchar\the\mathcode#1}
{\mathchar\the\mathcode#1}
}}
\AtBeginDocument{\mathcode#1=\string"8000 }
}
\@for\next:=1,2,3,4,5,6,7,8,9,0\do{\expandafter\changedigit\next}
\let\changedigit\@undefined
\makeatother

\begin{document}

$1234567890^{1234567890}$

$10x_0 + 11y_1$

\end{document}


You might want to add \scriptscriptstyle in the third argument to \mathchoice, which would give

or play with \DeclareMathSizes (see https://tex.stackexchange.com/a/58144/4427)

If you want to have all digits always oldstyle, change the code between \makeatletter and \makeatother into

\makeatletter
\@for\next:=1,2,3,4,5,6,7,8,9,0\do{%
\begingroup\edef\x{%
\mathcode\next=\noexpand\number\numexpr\mathcode\next-"7000+"100\relax}%
\edef\x{\endgroup\x}\x
}
\makeatother


Of course, this last code can be substituted with

\DeclareMathSymbol{0}{\mathord}{letters}{0}


and similar lines for the other digits.

• you might try this as a "good bad example": $10x_0 + 11y_1$ Sep 10 '13 at 16:04
• @barbarabeeton WOW! ;-) Sep 10 '13 at 16:06
• hmmm. now that i see the result, i think $3z_3$ or $9z_9$ would add some "interest". the likelihood that this combination of styles might be applied to material with pre-scripts is pretty low, but that could inject even more possible ambiguity. Sep 10 '13 at 16:52
• @bernard Note that I changed the code (the digit 8 was missing). Try the input proposed by barbara and you'll see why I consider this bad style. Sep 10 '13 at 16:56
• one place where old-style figures are good in "math" is in tables with long strings of numbers, or the expansion of a numerical representation of $\pi$. the varying shapes helps keep one from "getting lost". but be sure (in tables) to use digits with uniform widths. in the "text" form of digits, some (such as "1") are naturally narrower. Sep 10 '13 at 16:56