Incorrect Usage of \mathcal and \mathbb Leads to Interesting Symbols [duplicate]

I noticed that some incorrect usage of the \mathcal and \mathbb command generates interesting symbols.

\mathcal{M^1} \mathcal{M^2} \mathcal{M^3} \mathcal{M^4} \mathcal{M^5}


and

\mathbb{M^1} \mathbb{M^2} \mathbb{M^3} \mathbb{M^4} \mathbb{M^5}


Is this an expected behaviour? It seems that this is not what should be expected. I am wondering why would this happen instead of an error being thrown?

• Probably you're seeing the glyphs that the font has in the slots for the numbers... Jun 2 at 20:36
• Yes: tex.stackexchange.com/a/428214/38080 (1 is in the slot 49, etc...) Jun 2 at 20:40
• The fonts for \mathcal and \mathbb (which are provided only as uppercase alphabets) contain other symbols packed in to fill the fonts. So only the actual argument of either of those commands should be in braces: \mathcal{M}^1. (Yes, a duplicate.) Jun 2 at 20:46
• The short answer (see the links in the comments above for the long answer): \mathcal and \mathbb select a different font, where regular characters such as M but also 1 are mapped to various symbols. The numbers-mapped-to-symbols are usually not entered directly, but called using macros such as \infty, which is internally defined as \mathchar"231, where 2 is the family and 31 is the hexadecimal code for the character 1. Jun 2 at 20:48