12

This is not so much a practical question as one of curiosity. I realize that if I want to define my own symbol, practically speaking, I would want to use \newcommand or something similar, and could define the macro by superimposing existing characters or using TikZ/PGF or any number of other sensible ways. I understand that TeX itself was developed long before Unicode, and so the basic symbols of TeX are defined by TeX itself in some way and not borrowed from Unicode codepoints. What I want to know is, how does TeX define/represent the basic symbols that it uses and which are not, say ASCII characters? Does it use its own encoding filled with definitions for things like \in and \cap, or does it directly define them using a low-level TeX version of the TikZ-type approach mentioned above, or neither? How does all of this relate to METAFONT?

1 Answer 1

15

TeX only deals with characters in the the range 0 to 255. If it encounters letters in the input, that is characters with category code 11 assigned to them, it looks up the symbol in the font table of the currently set font and uses the character/glyph from that font.

That limits the number of representable characters, as you may want to have more than 256 different characters in your document. So what you can do is to use the \font command to define different fonts and change them at different places in your document. If TeX encounters a letter character or something similar such as a \char command, which denotes a character directly by its character code/ASCII number, it would then choose the character from that other font. As an example A (usually) gives the same result as \char65.

You can also define new commands that expands to some text representing a character preceded by a font selection command. The cases of \in or \cap you mentioned are kind of such commands, but they are still a bit different because they only work in math mode (in fact, they are defined to be math characters). In math mode, the command \mathchar can be used to choose a character from one of 16 simultanously loaded math fonts. So math chars are kind of the math equivalent of a combination of a font choosing command and a character in text mode.

For instance, \cap is defined as \mathchar"225C which means \cap is a math character of class 2 (= binary operator, the first 2), from math font number 2 (the second 2) at position 92 in the font table (92 is the decimal representation of 5C).

The original fonts by Knuth where all created using METAFONT, as far as I know, but that code isn't used by TeX directly, it's all hidden (in a compiled format) in the font tables which TeX chooses its character from.

0

You must log in to answer this question.

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