[Tex/LaTex] How to make all digits oldstyle

fontsoldstylenums

What should I put in my document's preamble so that digits are oldstyle?

Not "digits in textmode", "digits". Mathmode as well. I know some people dislike oldstyle digits in mathmode because they make $a^{36}$ look wrong, but I won't need numbers that large in superscripts or subscripts. And I need them in mathmode for tables which need to be {array}s rather than {tabular}s because they contain many mathematical formulae or \mathcal letters.

I have tried font-packages cfr-lm, hfoldstyle, eco and kpfonts, to no avail.

I'm using MikTeX.

I would rather keep the Computer Modern look. It has a larger (thus more legible, thus better) x-height than the alternatives I've seen, and I like its mathematical glyphs.

Proportionally-spaced oldstyle digits in textmode and fixed-width oldstyle digits in mathmode would be even better — if that is possible!

Here's one attempt, using the font-package cfr-lm which gives a Computer Modern lookalike, and old-style digits in text mode (which is progress) but still with lining digits in math mode.

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath} % for \boxed

% See frabjous's comment to https://tex.stackexchange.com/q/2852 
%\usepackage[oldstylenums]{kpfonts}
\usepackage{cfr-lm}

\begin{document}

0123456789 are text-mode digits. 1719--1811.

$0123456789$ are inline maths-mode digits. Now comes a tabular:

\begin{tabular}{r}
111367\\890111
\end{tabular}
and an array
$\begin{array}{r}
111367\\890111
\end{array}$

\boxed{\begin{matrix}
a+3&b-2\\
65&17
\end{matrix}}

\end{document}

Best Answer

Change the standard assignment of digits to the text font.

\documentclass[12pt,a4paper]{article}
\usepackage{cfr-lm}
\usepackage{amsmath} % for math

\DeclareMathSymbol{0}{\mathalpha}{letters}{`0}
\DeclareMathSymbol{1}{\mathalpha}{letters}{`1}
\DeclareMathSymbol{2}{\mathalpha}{letters}{`2}
\DeclareMathSymbol{3}{\mathalpha}{letters}{`3}
\DeclareMathSymbol{4}{\mathalpha}{letters}{`4}
\DeclareMathSymbol{5}{\mathalpha}{letters}{`5}
\DeclareMathSymbol{6}{\mathalpha}{letters}{`6}
\DeclareMathSymbol{7}{\mathalpha}{letters}{`7}
\DeclareMathSymbol{8}{\mathalpha}{letters}{`8}
\DeclareMathSymbol{9}{\mathalpha}{letters}{`9}

\begin{document}

0123456789 are text-mode digits. 1719--1811.

$0123456789$ are inline maths-mode digits. {\boldmath$0123$\textbf{0123}}

Now comes a tabular:

\begin{tabular}{r}
111367\\890311
\end{tabular}
and an array
$\begin{array}{r}
111367\\890311
\end{array}$

$\boxed{\begin{matrix}
a+3&b-2\\
65&17
\end{matrix}}$

\end{document}

enter image description here