The following example produces
Why does it not produce the following instead?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.Sign up to join this community
The TeXbook p. 289 explains how
\char〈8-bit number〉 can form a 〈character〉, and that a 〈character〉 is a particular case of a 〈math symbol〉. What a 〈math symbol〉 found in math mode does is explained on page 291, but let's get back to page 289 about 〈character〉:
When TeX is in math mode or display math mode, a 〈character〉 command takes on added significance: It specifies a number between 0 and 32767 = 215 − 1. This is done by replacing the character number by its
\mathcodevalue. If the
\mathcodevalue turns out to be
"8000however, the 〈character〉 is replaced by an active character token having the original character code (0 to 255); TeX forgets the original 〈character〉 and expands this active character according to the rules of Chapter 20.
So, what matters when finding
\char〈8-bit number〉 in math mode is the
\mathcode of the specified character. In your case, the character is number 5, i.e.
`\^^E. Line 59 of plain.tex reads:
\mathcode`\^^E="023A % \lnot
\char"5 in math mode is a 〈math symbol〉 with
"023A. It specifies class 0 (ordinary, cf. TeXbook p. 154), family 2 and position
"3A in the corresponding font.
The font in question is thus
\textfont2, because your
\rm does nothing here, AFAICT:
\rm: macro:->\fam \z@ \tenrm
\fam has an effect on symbols of class 7 (variable), but here the symbol has class 0; besides,
\tenrm affects the text font and has no effect in math mode, AFAIK (except of course if you temporarily leave math mode using, for instance, an
\hbox command inside the dollar signs).
You may query what this font is with:
> \tensy . l.3 \showthe\textfont2
and confirms what can be seen with
Completed box being shipped out  \vbox(667.20255+0.0)x469.75499 (...) .\vbox(643.20255+0.0)x469.75499, glue set 633.20255fill ..\glue(\topskip) 5.69446 ..\hbox(4.30554+0.0)x469.75499, glue set 443.0883fil ...\hbox(0.0+0.0)x20.0 ...\mathon ...\tensy : ...\mathoff (...)
: indeed has ASCII code
"3A. So, the character you get in the output is found in position
"3A of font
\tensy. The TeXbook p. 350 (plain.tex) declares:
You can verify with
texdoc encguide (page 33 here) that character
"3A of font
cmsy10 is indeed the
\lnot we see on your screenshot.
Note: this is not directly related to the question, but since its crux is the
\mathcode and the paragraph I quoted from the TeXbook explains what happens with the special case of a
\mathcode equal to
"8000, I'll seize the opportunity and point our dear readers to this answer of egreg where the
"8000 special case is put to good use (cf. function
\__hs_cls_activate_comma: in his answer).