1

TeX is amazingly customizable. I would never do this, but I am curious whether TeX possesses the following functionality:

As I understand it, TeX reads in a stream of bytes, and assigns each a category code. A letter or other character byte, if it is not part of a control sequence, is processed literally, by looking up the byte in the current font table (in horizontal or vertical mode), and looking up the byte 's mathcode in math mode.

Thus, if the byte 0x61 (ASCII a) currently has catcode 11, then in horizontal or vertical mode, the glyph at position 0x61 in the font table will be placed in the current list (as long as the byte is not part of the name of a control sequence, or part of a macro).

I am wondering whether it is possible to alter this functionality -- to, for instance, place the glyph at position 0x62 instead, when inputting byte 0x61. I suppose this is possible in math mode, with the \mathcode primitive, but is there a way to do something like this in horizontal or vertical mode? Again, not that I want to do this, but I'm playing around with the boundaries of TeX's capability and am curious whether this is a thing.

4

The way to do what you ask in classic tex (or xetex) is to use a virtual font, this is commonly done for math fonts. To tex a virtual font is identical to a real font (it sees exactly the same tfm structure) but each "glyph definition" in the real font is essentially a fragment of dvi code that can use any characters (or rules) from other included fonts.

1

For most characters in UTF-8 (the default encoding in LaTeX), you can do this with \DeclareUnicodeCharacter or the newunicodechar package. These allow you to make a character active and map it to an arbitrary command.

If you tried to make an ASCII character active, though, this would fail (and wreck the parsing of any command containing the letter a).

In XeTeX, you have the option of declaring a text mapping.

  • yes but not with the example in the question of a as if you make a active stuff will break, and \DeclareUnicodeCharacter will parse as \Decl areUnicodeCharacter – David Carlisle Jan 20 at 16:19
  • @DavidCarlisle Good point. I should mention how to do this in fontspec. – Davislor Jan 20 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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