11

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}

2 Answers 2

12

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

3
  • This worked for me, using LuaLaTeX and without my having to install anything else by hand. Moreover, I found that mathmode digits are monospaced, as desired, as $11$ showed for me. I don't know how come they turned out proportionally-spaced for you.
    – Rosie F
    Commented May 17, 2020 at 6:05
  • I note that loading cfr-lm replaces the glyph for double-quote (ASCII 0x22). So " is no longer good enough as a close-double-quote; it has to be ''.
    – Rosie F
    Commented May 17, 2020 at 6:43
  • 3
    @RosieF I guess that I used the image from a previous version. I'll fix it. You should never use " for closing quotes anyway.
    – egreg
    Commented May 17, 2020 at 9:37
7

(An up-front comment: I do not think that it's a good idea to use oldstyle numerals in math mode. But, since you asked...)

I don't know how to achieve your formatting request with pdfLaTeX. However, it's straightforward to achieve it with LuaLaTeX (or XeLaTeX) and the fontspec and unicode-math packages.

enter image description here

%%% compile with LuaLaTeX or XeLaTeX
\documentclass{article}
\usepackage{amsmath,array,booktabs} 
\newcolumntype{C}{>{$}c<{$}}
\usepackage{unicode-math}
\defaultfontfeatures{Renderer=OpenType}

%\setmainfont{Latin Modern Roman}%
%     [Numbers={OldStyle,Proportional}]
%\setmathfont{Latin Modern Math}
%\setmathfont{Latin Modern Roman}%
%     [range=up/{num},Numbers={OldStyle,Monospaced}]

\setmainfont{Libertinus Serif}[Numbers={Proportional,OldStyle}]
\setmathfont{Libertinus Math}
\setmathfont{Libertinus Serif}[range=up/{num},Numbers={Monospaced,OldStyle}]

\begin{document}
Text mode: 0123456789, pp.\ 1668--2759.

Math mode: $0123456789$, $16+38=54$.

\smallskip

\begin{tabular}{@{}cC@{}}
\multicolumn{2}{c}{Type of spacing}\\
\cmidrule(lr){1-2}
prop. & $mono.$ \\
(text)& $(math)$\\
\midrule
111111 & 111111 \\
333333 & 333333 \\
222222 & 222222 \\
888888 & 888888 \\
999999 & 999999 \\
000000 & 000000 
\end{tabular}

\smallskip

\boxed{\begin{matrix}a+3&b-2\\65&17\end{matrix}}
\end{document}
2
  • "not...a good idea to use oldstyle numerals in math mode" Fine -- could you go into detail as to why? I know that $a^{36}$ can look bad, and perhaps $\dfrac{a}2$ seems to have too much vertical space below the bar because 2 doesn't ascend; anything else? In my situation numerals and formulae won't mix, and there are lots of matrices with numerals, where ascenders and descenders help in legibility.
    – Rosie F
    Commented May 17, 2020 at 4:53
  • 1
    @RosieF - "Anything else?" I thought I provided another reason in the tabular environment that's posted in my answer: line spacing can look extremely uneven (and therefore distracting -- which, to me, is something that must be avoided at nearly all cost) if oldstyle numerals are used.
    – Mico
    Commented May 17, 2020 at 4:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .