How can I get a correct font identifier with \showthe and \the after it is overwritten? The MWE is below (Same result with all of Knuth TeX, pdfTeX, XeTeX, (e-)pTeX, (e-)upTeX and Aleph. Only LuaTeX behaves differently, which returns \X for all tests.)

%#!plain TeX
\font\X=ec-lmr10\X % set \X to the current font
\font\Y=ec-lmr10   % same as current font
\showthe\font % > \Y (most recently defined CS that selects the same font)
\showthe\X    % > \Y (same as above)
\showthe\font % > \Y (!!!)
\showthe\X    % > \Y (!!!)

The TeXbook says

\thefont⟩ produces a font identifier that selects the specified font. For example, ‘\the\font’ is a control sequence corresponding to the current font.

The free book TeX for the Impatient explains the behavior in more detail (as mentioned in This answer)

\thefont⟩, which expands to the most recently defined control sequence that selects the same font as the control sequence ⟨font

However, both of them fails to explain the behavior as noted with (!!!).

  • LuaTeX would show the same behavior if luaotfload.sty were loaded (which is the default in LuaLaTeX). The observed difference occurs because LuaTeX will load the same font multiple times by default. Jul 27, 2019 at 9:08

1 Answer 1


You should look at modules 548,222, 233, 234 of tex.web.

The output of \showthe\X in the last case is shown as \Y, but this is a “frozen” version of \Y, that has no relation with the current meaning \Y might have.

The same font (precisely, tfm file) can be associated to a control sequence any number of times, but the font will only be loaded once. The font number (font_id_base) points to the (frozen) control sequence that selects the same font assigned last. There is no way to recover the control sequence name the font was associated to first.

If I try

\font\X=ec-lmr10 \X % set \X to the current font
\font\Y=ec-lmr10    % same as current font

Non bold

\tenbf Bold text % to ensure we have changed the current font

\def\Y{Whatever} \Y % redefine \Y

\edef\test{\the\X} {\tt\meaning\test} % it shows macro:->\Y

\test Non bold % however it chooses the expected font


enter image description here

  • Many thanks for this investigation! This is... disturbing. So, one can't trust \show or \meaning to tell precisely what's in a macro. If I insert \def\foo{\Y} \show\test \show\foo \ifx\foo\test same\else different\fi in your example after your comment it shows macro:->\Y, the two \show commands can make us believe that \test and \foo have the same meaning, but as the \ifx and the end of your example demonstrate, they don't!
    – frougon
    Jul 27, 2019 at 13:58
  • 1
    @frougon Yes, if I add \def\testb{\Y} and do \ifx\test\testb I get false. Font memory management had been a big problem and Knuth did many optimizations around it. This is one.
    – egreg
    Jul 27, 2019 at 14:03

You must log in to answer this question.

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