TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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}
share|improve this question
Related to, but not quite a duplicate of Font substitution with XeLaTeX. – J. C. Salomon Jul 12 '12 at 21:53
Possible duplicate of Fontspec: Palatino with small caps and old-style figures; at least Khaled Hosny’s answer covers this question. – J. C. Salomon Jul 13 '12 at 16:19
Would you please point to a description of the fonts you're using? If they are free, we can test them. – egreg Jul 20 '12 at 8:43

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{}.

share|improve this answer
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. – Tobias Schula Jul 12 '12 at 22:17
@TobiasSchula, as I explained, this is not within the bailiwick of fontspec. – J. C. Salomon Jul 12 '12 at 22:24

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.
share|improve this answer
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. – Tobias Schula Jul 18 '12 at 23:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.