TeX: The Program
Overview
TeX: The Program presents the complete implementation of the TeX typesetting system as a literate program. The book prints Donald Knuth's WEB source: a tightly woven combination of Pascal code and explanatory prose that documents every algorithm and data structure used by TeX. It functions simultaneously as a readable narrative of design decisions and as an exact program listing that can be processed into compilable Pascal code.
Knuth organizes the material so the source and commentary illuminate one another. Readers encounter implementation details alongside discussions of purpose, invariants, and the constraints that shaped each algorithm, making the code comprehensible at both conceptual and practical levels.
Content and structure
The text is divided into modular sections, each labeled and cross-referenced, following the WEB convention of small, numbered "modules" that can be rearranged to form the full program. Major topics include tokenization, mouth and stomach processing, box model construction, glue and penalty handling, paragraph breaking (the Knuth, Plass algorithm), hyphenation, math typesetting, font metric handling, and DVI output generation. Data structures such as nodes for horizontal and vertical lists, glue specifications, and memory management routines are explained alongside the code that manipulates them.
Appendices and indexes help track identifiers and modules, and the source is presented so TANGLE can produce Pascal code while WEAVE can produce typeset documentation. Historical notes and changelogs record the evolution of the program up to the published version.
Approach and style
Knuth's prose is concise and rigorous, aimed at conveying both the "how" and the "why" of the implementation. Explanatory passages frequently justify design choices, state invariants, and point out subtleties that could lead to bugs. The literate-programming style emphasizes readability: short, focused modules are interspersed with commentary that anticipates readers' questions and guides them through intricate interactions among components.
The presentation balances algorithmic precision with practical concerns of efficiency and portability. Code fragments are annotated with assertions and explanatory notes that reveal trade-offs and constraints inherent to high-quality typesetting.
Intended audience and uses
The book targets experienced programmers, implementers, and researchers who need a complete, faithful account of TeX's internals. It is most valuable to those seeking to understand, port, maintain, or extend the engine, and to readers interested in the techniques behind professional-quality digital typesetting. Casual users of TeX will find the material dense, but those with a background in programming and algorithms will appreciate the depth and clarity.
Because the source is canonical, the book serves as a reference for anyone investigating TeX's behavior, verifying correctness, or studying its algorithms for research and teaching.
Significance and legacy
TeX: The Program exemplifies literate programming and stands as a canonical record of a major software artifact. The combination of code and thorough explanation set a high standard for software documentation and reproducibility. Knuth's careful exposition of algorithms such as paragraph breaking and hyphenation influenced subsequent work in digital typesetting and algorithm design, while the WEB methodology inspired generations of programmers to favor readability and explanatory code.
Beyond its technical content, the book is a historical document that preserves the reasoning and craft behind a system that reshaped scholarly publishing and produced consistently high-quality typeset output across platforms.
Citation Formats
APA Style (7th ed.)
Tex: The program. (2026, February 15). FixQuotes. https://fixquotes.com/works/tex-the-program/
Chicago Style
"TeX: The Program." FixQuotes. February 15, 2026. https://fixquotes.com/works/tex-the-program/.
MLA Style (9th ed.)
"TeX: The Program." FixQuotes, 15 Feb. 2026, https://fixquotes.com/works/tex-the-program/. Accessed 19 Feb. 2026.
TeX: The Program
A literate-programming presentation of TeX’s source code, explaining the full implementation in WEB style and serving as both documentation and a program listing.
- Published1986
- TypeBook
- GenreComputer Science, Typesetting, Literate programming, Reference
- Languageen
About the Author

Donald Knuth
Donald Knuth, detailing his work on algorithms, The Art of Computer Programming, TeX, literate programming, teaching, and lasting influence.
View Profile- OccupationScientist
- FromUSA
-
Other Works
- The Art of Computer Programming, Volume 1: Fundamental Algorithms (1968)
- The Art of Computer Programming, Volume 2: Seminumerical Algorithms (1969)
- The Art of Computer Programming, Volume 3: Sorting and Searching (1973)
- Surreal Numbers: How Two Ex-Students Turned on to Pure Mathematics and Found Total Happiness (1974)
- The TeXbook (1984)
- METAFONT: The Program (1986)
- The METAFONTbook (1986)
- Concrete Mathematics: A Foundation for Computer Science (1989)
- Literate Programming (1992)
- Selected Papers on Computer Science (1996)
- Digital Typography (1999)
- Selected Papers on Analysis of Algorithms (2000)
- Selected Papers on Fun and Games (2005)
- The Art of Computer Programming, Volume 4A: Combinatorial Algorithms, Part 1 (2011)
- 3:16 Bible Texts Illuminated (2013)
- The Art of Computer Programming, Volume 4B: Combinatorial Algorithms, Part 2 (2023)