[Tex/LaTex] Utilizing oldstyle figures without resorting to \oldstylenums

fontsoldstylenumspdftex

Quite a few of the freely available LaTeX fonts include oldstyle figures (numerals that harmonize with lower case letters) in addition to lining figures. (Generally, you have to load the textcomp package to make the additional symbols available.) However, only a few font packages provide an easy switch to oldstyle figures – the ones I know that are freely available are

  • \usepackage[osf]{mathpazo} (for the Palatino font),

  • \usepackage[osf]{libertine}, and

  • \usepackage{cfr-lm} (for the Latin Modern font).

For other fonts, one may use the \oldstylenums macro to access oldstyle figures, typing (e.g.) \oldstylenums{123} in every single instance. This is impractical and tedious.

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{textcomp}

\usepackage{tgschola}% or, e.g., tgtermes, cmbright, iwona

\begin{document}

\Large

0123456789

\oldstylenums{0123456789}

\end{document}

enter image description here

I know that XeLaTeX allows for easy access to Open Type Font features (among them oldstyle figures). However, I'm interested in (pdf)LaTeX for the moment. Is it possible to conveniently utilize oldstyle figures for every LaTeX font that includes them?

Best Answer

There isn't generally a single answer for this. It all depends on the fonts and font tables that the font foundry provides and how they're mapped and installed in your TeX system. Let me try to explain.

[To make things less confusing, the answer that follows assumes your question is directed at LaTeX scenarios, rather than XeTeX, LuaTeX etc. which provide different and somewhat simpler ways to approach this.]

Assuming that your fonts are properly installed in your texmf directory stucture, and perhaps assuming outline (non-bitmap) fonts, you'll have several sets of fonts (let's say, "shapes" and/or "series") for each typeface. Depending on the particular typeface, i.e., depending on what the particular font foundry has provided, you will have shapes/series for regular, bold, italic, bold-italic as a minimum (although in some cases there might be less), and then possibly, old style nums, true caps, condensed, alternative weights etc (usually from 'Pro' or 'expert' collections).

Now, TeX can access the oldstyle nums provided in your fonts in several ways, depending on how the font has been created or (more accurately) how its mappings are laid out on your system. In cases where you have dedicated oldstyle font files, all TeX needs to do to switch from oldstyle figures to lining figures is to switch its tables pointing at them in its mappings. And all you need to do is specify what you want by selecting them. Here are some examples:

Font Family       lining figures   old style figures
----------------------------------------------------
Kepler Project        jkpx             jkpxosn
ADF Venturis          yvt               yvtj
Palatino              pplx              pplj
Adobe Sabon           psb               psbj
Adobe Minion Pro   MinionPro        MinionPro-OsF

To select, say, Palatino with lining figures as the default Roman font, write \renewcommand*\rmdefault{pplx} in your document preamble, or \renewcommand*\rmdefault{pplj} if you want Palatino with oldstyle nums. That's all that's happening underneath when you write \usepackage[osf]{mathpazo} to load up Palatino with Pazo math fonts.

Alternatively, if you want to use Palatino with oldstyle nums at a particular place in your document, you might write \fontfamily{pplj}\selectfont. If you do that while you're in a group (e.g., inside an inner { and }), you'll revert to the font that was in effect when you leave the group. As above, this is all that mathpazo is doing for you when you write \oldstylenums{12345}. I.e., mathpazo includes the command (notice the group):

\renewcommand{\oldstylenums}[1]{{\fontfamily{pplj}\selectfont #1}}

Not too many font foundries give you this ease of access to old style figures (mostly because these extra sets make up their 'Pro' collections for which they charge more, or because it's extra work, or because oldstyle nums don't look so fantastic in that particular typeface).

However, as with GUST e-foundry, some font makers provide oldstyle figure glyphs outside the usual slots for these. In other words, you get the usual set of lining figures as well as oldstyle figures through symbol glyphs mappings (TS1 vs T1 encodings). If your mappings have been set up properly (e.g., by fontinst or if someone has done this work for you), you can access lining figures in the usual way ('1', '2',...) and oldstyle figures through commands like \textzerooldstyle, \textoneoldstyle, etc. The trouble is, you can't easily switch in and out of lining and oldstyle figures just by selecting them as we saw in the Palatino example above. This is reason the fontaxes approach (per Lev's and lockstep's suggestion) won't work - for Gyre Schola, it's looking for font definition qcsj or qcs-OsF and can't find either (qcs is the base fontfamily name for Gyre Schola). However, without the fontaxes package loaded, \oldstylenums (defined in the textcomp package) can access them. You can see how it does this by fooling around a little like this:

\documentclass{article}
\usepackage{tgschola}                % or whatever
\usepackage{textcomp}                % no real need to explicitly load textcomp in this case
\usepackage{fontenc}                 % to control your font encoding

\begin{document}
T1 font encoding:\par
\fontencoding{T1}\selectfont
01234567890\par                      % lining figures under T1 encoding, osf under TS1
\oldstylenums{01234567890}\par       % forces TS1 encoding, so typeset osf regardless
abcdefghijABCDEFGHIJ\par             % normal chars under T1 encoding, gobbledygook under TS1
\oldstylenums{abcdefghijABCDEFGHIJ}  % forces TS1 encoding, so typeset symbols regardless
\vspace{\baselineskip}

TS1 font encoding:\par
\fontencoding{TS1}\selectfont
01234567890\par                      % lining figures under T1 encoding, osf under TS1
\oldstylenums{01234567890}\par       % forces TS1 encoding, so typeset osf regardless
abcdefghijABCDEFGHIJ\par             % normal chars under T1 encoding, gobbledygook under TS1
\oldstylenums{abcdefghijABCDEFGHIJ}  % forces TS1 encoding, so typeset symbols regardless
\end{document}

If you do this, you'll quickly see that all that \oldstylenums is doing is switching in and out of TS1 encoding. However, you can see by the nonsense that is printed when you try to typeset normal characters in TS1 font encoding that you mustn't select that encoding when wanting to typeset normal text! Thus, you have to somehow tell LaTeX before entering and after leaving every block of oldstyle nums that this is what you want to do. I.e., you're back to using \oldstylenums, although perhaps by some other name.

There is a third way, which is to set up a set of virtual fonts that assemble the oldstyle figures the font provides into the slots where the normal figures usually reside. This takes some expertise and probably shouldn't be entered lightly but is completely do-able if you have the patience and time to spare.

Related Question