This is a partial re-asking of my question Can I change the font and colour of a letter permanently?. The answers there focussed on the colour aspect of what I wanted. I also want to be able to change the actual font used for a character.

What's the right way to reassign a character to a particular glyph from a particular font?

As a possible (albeit slightly manic) example, suppose I wanted (in maths mode) to use C just for the set of complex numbers. So typing C should produce ℂ. I also want to be able to shift the glyphs around, so maybe typing d should produce δ.

Will's answer to my original question began with:

In regular latex you can choose different fonts for different symbols

but didn't tell me exactly how to do that!

3 Answers 3


The first argument is the token (control sequences are valid here) you're defining. The second is the class, \mathord, \mathbin, \mathop, \mathrel, \mathopen, \mathclose, \mathpunct, and 7 for variable (there's probably some \mathfoo for variable, but I don't know what it is). The third is the font family. The fourth is the position within that family.

As would be expected, this particular case eventually expands to a \mathcode `C="0.43. I don't really know what the missing hex digit (the family) is. \mathcode is one of those mysterious (to me) primitives.

I believe the basic format is: \mathcode `x="cfpp where x is any literal character, c is the class (0 = ordinary through 7 = variable), f is the family, and pp is the position within that family. cfpp is a hexadecimal value, of course.

It occurs to me that you might want to use 7 instead of \mathord to get a letter in the variable class. I'm not sure. Hopefully someone else can express an opinion on the matter.

  • That's probably enough for me to work out the rest, but if you happen to know a link to an explanation of what the fields mean (or can put it in yourself), that'd be much appreciated! Commented Sep 10, 2010 at 10:01
  • Sorry, this isn't my greatest answer ever. Hopefully someone will come give a better answer.
    – TH.
    Commented Sep 10, 2010 at 10:14
  • Is it possible to do something similar for text symbol? I have EBGaramond font but the "1" display is not very readable. I'd like to change it while keeping EBGaramond. Commented Nov 12, 2020 at 9:17
  • For text symbol see luatex - Substitute a character by another one (Lualatex) - TeX - LaTeX Stack Exchange for example
    – user202729
    Commented Jun 13, 2022 at 16:36

Just an example to get you started; see texdoc fntguide for the complete documentation.


This doesn't have a proper user interface in unicode-math yet, since it's a somewhat obscure feature to have. But I'll definitely keep it mind when I do my next round of updates.

  • As a matter of fact, this question came out of trying to hack unicode-math to allow me to do exactly that. Then further reading of unicode-math led me to realise that every time I call 'setmathfont', I set up a whole new font - even for just one character! So better to set up the fonts at the start and then just use them each time. But that needs the reassignment code. Commented Sep 10, 2010 at 12:42
  • I agree that it sounds a little obscure at first, but the more I think about it the more ways I can think to use it! Just imagine giving a seminar on cryptography where the lecturer wants to show how different letters occur in text. On one frame, everything's black. On the next, all the letter 'e's appear in green. Though, having read your last blog post, I think that you have more important things to do right now than implement this! Commented Sep 12, 2010 at 13:22
  • Changing the colour is one thing, and I agree, but remapping C to \mathfrak{C} is less convincing :) It certainly makes the source much less portable. Commented Sep 12, 2010 at 22:36
  • Agreed, and that's not actually what I want to do. All I really want to do is shift a character to boldface (for vectors). So if 'bf' were on the same level at 'up' and 'it' in your unicode-math package, then I'd be happy. By the way, I've now gotten a working system with the colours and all that. If you want to see what it looks like, take a look at the latest lecture (beamer or trans versions) at math.ntnu.no/~stacey/Teaching/TMA4145h2010/lectures.html I think maybe it's a bit garish, but I'm still experimenting with what looks best. Commented Sep 14, 2010 at 19:40

Even though there already is an accepted answer, I wanted to chip in one thought. The only "shifting" that comes to mind would require XeTeX, a font which has everything packed in (latin, greek, etc.), and knowing how much to "shift". Ie.

\count0=0 \advance\count0 by \XeTeXcharglyph`A
\advance\count0 by 500% Or how much it is to shift until the wanted version
\XeTeXglyph\count0% Out comes the shifted glyph

Of course, all this would need to be macro'd somehow. I'm sorry I don't know macroing well enough to be of help here, but hopefully the basic idea could provide some food for thought.

You must log in to answer this question.

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