I recently read a blog post on literate programming and that tex was written using this paradigm. So I thought it might be a good idea to read the original tex program's source, by Knuth himself (the pascal version) in the literal programming style. However, having downloaded the distribution, I only find the raw file tex.web in the directory, and the tooling available via package managers (ctangle, cweb) only works with C files.

So I was wondering whether a PDF file with the literate programming output was available on line, yet an hour of searching online did not yield a result. So: Is there the literate programming output for humans available for the tex processor?

  • 2
    The “weaved” version of tex.web is available on TeX Live with texdoc tex
    – egreg
    Commented Jul 10, 2016 at 21:08
  • 5
    @GustavoMezzetti the printed book provides additional value through mini-indexes crossreferencing functions/variables etc. That version is only available in book form but the raw formatted version from the .web source is generally availables and can be printed. This is different from the TeX book which is also available as source .tex file but you are legally not allowed to generate a printed version from it! Commented Jul 11, 2016 at 7:48
  • @FrankMittelbach: Thans for your enlightenment. It looks like I was sitting on a treasure without even knowing it! Now that I’m no longer afraid of being (pur)sued by Addison-Wesley’s lawyers, I can reveal that I had followed the .web >>Weave> .tex >>pdfTeX> .pdf path, but I thought that disclosing this trick on a web site would constitute copyright infringement, thus clearly violating TeX.SX policy; I was not aware of the fact that the PDF is directly available through texdoc! I’ll immediately remove my misleading comment, as well as this one in 48 hours.
    – GuM
    Commented Jul 11, 2016 at 18:09
  • A compiled source: tex.pdf
    – Werner
    Commented Jul 12, 2016 at 19:42

2 Answers 2


If you have tex.web, you can do

weave tex.web

and then

tex tex.tex

(or pdftex). This is the first page:

enter image description here

The PDF is anyway already available on TeX Live by texdoc tex.


The (commented) source code is sold as a book: Volume B: TeX: The program. A documented listing of the source code of the TeX interpreter of Computers and Typesetting.

You must log in to answer this question.

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