I just ran into another issue, I like to use gill sans very much but the number 1, lower case L and upper case I are almost indistinguisable. On the other hand I like Helvetica numbers. Is there a way to use Gill Sans for all non-numeric characters and Helvetica only for numbers [0 9] ?

  • 3
    I think it's likely that you just gave some of the people around here a migraine.
    – Kieran
    Commented Feb 4, 2011 at 16:25
  • 1
    I did ?, that was not my intention...
    – Gregthom
    Commented Feb 8, 2011 at 1:36

2 Answers 2


Yes, you can. But I only know a tricky method --- to use \XeTeXinterchartoks and related commands. There have been some packages, for example xeCJK and ucharclasses, that use this mechanism for multilingual support. (I wrote a few code for xeCJK.) For more information, you can read XeTeX's reference.

Set \XeTeXinterchartokenstate=1 to enable the mechanism.

There are already some predefined char classes. 0 for normal westen alphabets and symbols, 1 for CJK ideographs, 4095 for boundary (255 in older versions of XeTeX), etc. And you can use \newXeTeXintercharclass to allocate a new class.

Use \XeTeXcharclass to set the numbers to the new character class, and use \XeTeXinterchartoks to do the trick.

Full example:


% Test for old and new versions of the latex kernel
\TokSetfont={\begingroup\fontspec{Latin Modern Mono}}





BTW, this does not affect math fonts.

Note Code has been updated to reflect changes in XeTeX (but not actually reflected in the documentation.) If this code fails, remove the test for XeTeX version and just use \chardef\CharBound=4095. (There was one version of the kernel that did not have \e@alloc@intercharclass@top defined, but the class was still 4095.)

  • I second the suggestion of ucharclasses, somewhat reluctantly. It increased my compilation time by a factor of twenty, from ten seconds to two minutes. So now I need conditional compilation, with, among other things, special handling for the CMU Serif “~” bug. The lack of handling of missing characters in math fonts is particularly annoying, especially for a feature that should be (as it is on OSX) a built-in feature. Commented Mar 29, 2011 at 16:00
  • Every time I try to run this (using Overleaf), exactly copy and pasting your answer, I get an error: TeX capacity exceeded, sorry [save size=80000]., clearly an infinite recursion is happening somewhere. In fact, If I change Latin Modern Mono to Arial, then I see Font Arial does not contain any OpenType 'Script' information. hundreds of times in the log, indicating that the line \TokSetfont={\begingroup\fontspec{Latin Modern Mono}} is giving the recursion. Commented Feb 23, 2018 at 17:25
  • Also, this seems to override the Courier font which should always be used when calling \texttt{}. Is there a fix for that? Commented Mar 1, 2018 at 20:21

I don't know if this works in LaTeX, but at least with Plain:

\font\mydigitssfont="Helvetica/S=7" at 7pt
\font\mydigitsssfont="Helvetica/S=5" at 5pt
$ 1^22^{23^3}3^1 $ 123 {\mydigits 123}

So, automatic only for mathmode.

  • This works only for math fonts, which may not be what @Gregthom want. In LaTeX, math fonts for digits can be easily changed using \DeclareMathSymbol in NFSS scheme, without help of XeTeX.
    – Leo Liu
    Commented Feb 4, 2011 at 17:14
  • @Leo Liu: I managed to edit in that fact pretty much the same minute you left your comment :‑)
    – morbusg
    Commented Feb 4, 2011 at 17:18

You must log in to answer this question.

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