I have some trouble setting oldstyle numbers in my document. I load the font (in this case an early palatino) and define the smallcaps font via fontspec. But the oldstyle numbers are in the smallcaps variant of this font and don't display in the main text.

\setmainfont[ Numbers={Proportional, OldStyle}, SmallCapsFont={PalmerCapsOld} ]{Palmer}

2 Answers 2


What fontspec provides is syntax for enabling OpenType features. What you need is the ability to switch fonts every time numerals are displayed.

XeTeX has the XeTeXinterchartoks functionality to enable this; LuaTeX does not (at least not directly; see below).

For example, try this code:

% !TeX program = xelatex
\XeTeXinterchartokenstate = 1
\newXeTeXintercharclass \numeralsclass
\newXeTeXintercharclass \numeralsclass
    \XeTeXcharclass \count255 \numeralsclass
    \advance\count255 by 1

\XeTeXinterchartoks 0 \numeralsclass = {\bgroup\itshape}
\XeTeXinterchartoks 255 \numeralsclass = {\bgroup\itshape}
\XeTeXinterchartoks \numeralsclass 0 = {\egroup}
\XeTeXinterchartoks \numeralsclass 255 = {\egroup}

abc 123 def456jkl789



This code allocates a character class for numerals, then assigns it to 0–9.

Between character class 0 (letters) or 255 (non-characters: glue, kern, math, box, etc.) and the newly-defined character class for numerals, we insert a font change (\itshape for visibility); between numerals and class 0/255 we insert \egroup to undo that font change.

You should be able to apply this to your case something like this:

\setmainfont[ Numbers={Proportional}, SmallCapsFont={PalmerCapsOld} ]{Palmer}
\XeTeXinterchartoks 0 \numeralsclass = {\bgroup\scshape}
\XeTeXinterchartoks \numeralsclass 0 = {\egroup}
\XeTeXinterchartoks 255 \numeralsclass = {\bgroup\scshape}
\XeTeXinterchartoks \numeralsclass 255 = {\egroup}

But… you wanted a LuaLaTeX solution.

See In LuaTex is it possible to change font/language according to the script/glyphs used? for LuaTeX code that mimics XeTeXinterchartoks. The trouble is a difference in when the code executes; if I’ve understood Manuel Pégourié-Gonnard’s comment correctly, even code like \count255 might break.

You might be better off running a regexp search on your document, to surround each run of numerals with \textsc{}.

  • Thank you so far! Your example already works in XeLaTeX, I'll try it tomorrow in luatex. Maybe I should write the author of fontspec, because it's not uncommon to have the oldstyle numbers in the smallcaps font. Commented Jul 12, 2012 at 22:17
  • @TobiasSchula, as I explained, this is not within the bailiwick of fontspec. Commented Jul 12, 2012 at 22:24
  • Note that the non-character class currently has the number 4095 (since 2016) instead of 255.
    – Marijn
    Commented Mar 10, 2023 at 21:56

Quoting Khaled Hosny’s answer to Fontspec: Palatino with small caps and old-style figures, here’s another solution:

You need a Palatino with proper OpenType support, alternatively you can use TeX Gyre Pagella (which is true Palatino by Zapf, and further opentypified by GUST) which is included in TeXlive.


\setmainfont[Numbers=OldStyle]{TeX Gyre Pagella}

Text 12345.
  • Yeah, I already know about the TeX Gyre Collection. However this is not what I'm looking for. The Pagella is a modification of the URW Palladio, which is designed to mimic the Adobe Palatino, which is one of the core Postscript fonts. The Palatino I intend to use is based on the cut from the 50s, it has a more calligraphic style. Commented Jul 18, 2012 at 23:01

You must log in to answer this question.

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