Does anyone know how Knuth originally defined the famous TeX macro \TeX? Specifically, I want to know where I can find in, say, a TeXLive set of source files, of this macro being constructed.

I'm not asking so that I can recreate it or so I can better understand macros. I'm asking because I've been studying TeX source code/the TeXbook/tex.web for a while, but I'm still confused about its programming structure. All I can really gather is that some of it is written in WEB, Pascal, something called Pascal-H, then TeXLive made WEB2C to translate it to C, etc., so I feel that a concrete identification of where \TeX is defined in TeX source code would be helpful in sorting this stuff out.

  • 4
    You mean you want the code for the macro \TeX or for TeX the program itself. If it's the former, Knuth's definition is \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX} on line 693 of plain.tex. If you want the source of TeX, it's on CTAN. – Phelype Oleinik Nov 15 '20 at 2:20
  • Yes, the macro, thank you for pointing it out! – trujello Nov 15 '20 at 2:41
  • 4
    Though it has no relation to the definition of the macro \TeX, if (as you mention in the question) you're trying to study the TeX source code / tex.web, I was trying to do the same earlier and have some possibly helpful supporting material somewhere on this page. Hmm, looking at it again, it all looks disorganized and not very helpful, but FYI just in case… – ShreevatsaR Nov 15 '20 at 18:20
  • @ShreevatsaR In poking around the internet regarding TeX, I have actually already come across your site containing your notes and they're wonderful and impressive! Still parsing through it :) – trujello Nov 15 '20 at 19:43

The \TeX macro is defined in plain.tex as


or in LaTeX (ltlogos.dtx) as


(the difference is that LaTeX makes \TeX a robust macro, and adds the spacefactor correction \@).

You can use \show\TeX to see its definition in plain TeX, or in a recent LaTeX distribution, \ShowCommand\TeX:

> \TeX=robust macro:
->\protect \TeX  .

> \TeX =\long macro:
->T\kern -.1667em\lower .5ex\hbox {E}\kern -.125emX\@.
<argument> \TeX  
<*> \ShowCommand\TeX

This macro is hand-tuned to Computer Modern, so if you change fonts you might need to adapt the kerning.


The answer by Phelype Oleinik does give the definition for the TeX logo as it appears in the file plain.tex, but different values were used for the various kerns for other fonts that appear in the five volumes of Computers & Typesetting.

Knuth wrote an article for TUGboat explaining the differences and the reasoning behind the differences, and giving the values for fonts other than cmr in the Computer Modern family: "The TeX Logo in Various Fonts", TUGboat, Volume 7 (1986), No. 2, p.101


This answer adds nothing more than Phelype and Barbara already told you about the \TeX macro. However, for completeness sake, I just want to point out the existence of a command line tool named texdef that gives you the definition of TeX macros based on the provided parameters. In this case

[paulo@cambridge ~] $ texdef TeX

macro:->T\kern -.1667em\lower .5ex\hbox {E}\kern -.125emX

brings the original definition Phelype mentioned. By invoking the tool without any additional flags and options, texdef assumes TeX. If we explicitly ask for a LaTeX definition (-t latex),

[paulo@cambridge ~] $ texdef -t latex TeX

macro:->\protect \TeX  

\TeX :
\long macro:->T\kern -.1667em\lower .5ex\hbox {E}\kern -.125emX\@

the tool gives us the robust version as defined in LaTeX.

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.