# Changing Fonts between \textstyle and \scriptstyle with MTPro2

I'm a fan of Spivak's MTPro2 fonts, except for the fact that the numerals don't quite match the regular Times (ptm) numerals. Is there a slick way to change the \displaystyle and \textstyle numerals to \rmdefault but keep the \scriptstyle and \scriptscriptstyle numerals? I only know an "all or nothing" approach.

Obligatory MWE:

\documentclass{article}
\renewcommand{\rmdefault}{ptm}
\usepackage[lite]{mtpro2}
\def\swap#1{\DeclareMathSymbol{#1}{7}{operators}{#1}}
\swap1 \swap2 \swap3 \swap4 \swap5 \swap6 \swap7 \swap8 \swap9 \swap0

\begin{document}
This 5 is nice, but is $5$? And how does $2^5$ and $5^2$ look?
\end{document}

• Welcome! I think the answer to this is 'No'. That is, it could be done but not, I think, in any way which a reasonably sane person could possibly be induced to describe as 'slick'. But since this is maths typesetting, better let a guru answer for sure. – cfr Aug 10 '15 at 1:07
• Why only in display and text style? – egreg Aug 10 '15 at 8:46
• @egreg I just like the way the smaller faces were designed is all. Switching using DeclareMathSymbol makes script and scriptscript just scaled-down versions of the regular face. – Jon Aug 12 '15 at 3:50

It's possible, by using \mathchoice and making digits “math active”:

\documentclass{article}
\usepackage{times}
\usepackage[lite]{mtpro2}

\begingroup
\makeatletter
\begingroup\lccode~=#1 \lowercase{\endgroup
\expandafter\xdef\csname digit\romannumeral#1code\endcsname{\the\mathcode#1\relax}
\gdef~{\csname digit\romannumeral#1\endcsname}%
}
\expandafter\gdef\csname digit\romannumeral#1\endcsname{{%
\mathchoice
{\operator@font\mathchar\csname digit\romannumeral#1code\endcsname}%
{\operator@font\mathchar\csname digit\romannumeral#1code\endcsname}%
{\mathchar\csname digit\romannumeral#1code\endcsname}%
{\mathchar\csname digit\romannumeral#1code\endcsname}%
}}%
\AtBeginDocument{\mathcode#1="8000 }
}
\endgroup

\begin{document}

This 5 is nice, but is $5$? And how does $2^5$ and $5^2$ look?

{\scriptsize 5}$\scriptstyle 5$

{\scriptsize 01234567890}

$\scriptstyle 01234567890$

$\displaystyle 01234567890$

$\textstyle 01234567890$

\end{document}


However, digits will not obey \mathit` when in text or display style.