Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Why is it so hard to find TeX sources in C? I know the full source code is included in the tex.web and pdftex.web files, but isn't there any way to convert them to plain C code?

share|improve this question
LuaTeX's source code is in C. See foundry.supelec.fr/gf/project/luatex/scmsvn/… –  topskip Dec 4 '11 at 19:23
web2c will convert them to C –  Axel Sommerfeldt Dec 4 '11 at 19:27
@Patrick Aren't they still in WEB-style format rather than more standard C? –  Joseph Wright Dec 4 '11 at 21:59
@JosephWright I have to admit that I don't know. –  topskip Dec 5 '11 at 8:07
@Patrick I'm basing my understanding on tug.org/TUGboat/tb30-3/tb96hoekwater-pascal.pdf, which indicates that some WEB is retained. –  Joseph Wright Dec 5 '11 at 8:25

2 Answers 2

It's hard to find them because they don't exist. TeX is written in Pascal (one of the many flavors of it), but the source is interspersed with description of the code in the Web system devised by Knuth and others as part of a "literate programming" project.

The commented source is in tex.web (and tex.ch, a supplementary file where adaptations for specific operating systems are defined); one can get a tex.tex file by running

weave tex.web

and then compiling the file with tex or pdftex. The program code is obtained by running

tangle tex.web

that produces tex.p.

Modern distributions translate the Pascal code into C with a helper program, but I don't think that the C code is particularly readable. If you have available a TeX Live distribution, you can say

texdoc tex

which will open a PDF file with the commented Pascal code.

share|improve this answer
> It's hard to find them because they don't exist. Well, they exist temporarily. Obviously they must exist, because they get fed to the C compiler. The conversion utility that the OP asked about (and which you mentioned in passing) is called web2c; it takes the tex.p output from tangle and converts it to tex.c –  bubba Nov 24 '12 at 6:54

The C source code to Y&Y TeX, a once commercial product (Windows), has been released as free software. You can download it from http://code.google.com/p/yytex/

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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