TeX

TeX is a popular means of typesetting complex mathematical formulae; it has been noted as one of the most sophisticated digital typographical systems.

[6] When the second edition was published, in 1976, the whole book had to be typeset again because the Monotype technology had been largely replaced by phototypesetting, and the original fonts were no longer available.

The first version of TeX, called TeX78, was written in the SAIL programming language to run on a PDP-10 under Stanford's WAITS operating system.

TeX82 also uses fixed-point arithmetic instead of floating-point, to ensure reproducibility of the results across different computer hardware,[9] and includes a real, Turing-complete programming language, following intense lobbying by Guy Steele.

[14] Even though Donald Knuth himself has suggested a few areas in which TeX could have been improved, he indicated that he firmly believes that having an unchanged system that will produce the same output now and in the future is more important than introducing new features.

[15] Likewise, versions of Metafont after 2.0 asymptotically approach e (currently at 2.7182818), and a similar change will be applied after Knuth's death.

[16] Knuth created "unofficial" modified versions, such as TeX-XeT, which allows a user to mix texts written in left-to-right and right-to-left writing systems in the same document.

[17] In several technical fields such as computer science, mathematics, engineering and physics, TeX has become a de facto standard.

While such extensions have been created (including some by Knuth himself),[17] most people have extended TeX only using macros and it has remained a system associated with technical typesetting.

TeX is a macro- and token-based language: many commands, including most user-defined ones, are expanded on the fly until only unexpandable tokens remain, which are then executed.

[22] The system can be divided into four levels: in the first, characters are read from the input file and assigned a category code (sometimes called "catcode", for short).

The input for the third stage is then a stream of characters (including the ones with special meaning) and unexpandable control sequences (typically assignments and visual commands).

[24] These low-level commands are rarely used directly by users, and most functionality is provided by format files (predumped memory images of TeX after large macro collections have been loaded).

[25] The most widely used format is LaTeX, originally developed by Leslie Lamport, which incorporates document styles for books, letters, slides, etc., and adds support for referencing and automatic numbering of sections and equations.

Another widely used format, AMS-TeX, is produced by the American Mathematical Society and provides many more user-friendly commands, which can be altered by journals to fit with their house style.

Since the primary goal of the TeX language is high-quality typesetting for publishers of books, Knuth gave a lot of attention to the spacing rules for mathematical formulae.

[30][21] While TeX provides some basic rules and the tools needed to specify proper spacing, the exact parameters depend on the font used to typeset the formula.

[31] The typesetting of math in TeX is not without criticism, particularly with respect to technical details of the font metrics, which were designed in an era when significant attention was paid to storage requirements.

In comparison, the total-fit line-breaking algorithm used by TeX and developed by Donald Knuth and Michael Plass [37] considers all the possible breakpoints in a paragraph, and finds the combination of line breaks that will produce the most globally pleasing arrangement.

The algorithm will then find the breakpoints that will minimize the sum of squares of the badness (including penalties) of the resulting lines.

Further simplifications (for example, not testing extremely unlikely breakpoints such as a hyphenation in the first word of a paragraph, or very overfull lines) lead to an efficient algorithm whose running time is

However, in general, a thesis by Michael Plass shows how the page-breaking problem can be NP-complete because of the added complication of placing figures.

[38] TeX's line-breaking algorithm has been adopted by several other programs, such as Adobe InDesign (a desktop publishing application)[39] and the GNU fmt Unix command line utility.

The original version of TeX used a hyphenation algorithm based on a set of rules for the removal of prefixes and suffixes of words, and for deciding if it should insert a break between the two consonants in a pattern of the form vowel–consonant–consonant–vowel (which is possible most of the time).

[42][page needed][43] Metafont, not strictly part of TeX, is a font description system which allows the designer to describe characters algorithmically.

Broadly speaking, the running of this macro language involves expansion and execution stages which do not interact directly.

The TeX macro language has been used to write larger document production systems, most notably including LaTeX and ConTeXt.

The question of licence is somewhat confused by the statements included at the beginning of the TeX source code,[59] which indicate that "all rights are reserved.

This interpretation is confirmed later in the source code when the TRIP test is mentioned ("If this program is changed, the resulting system should not be called 'TeX'").

TeX allowed scientific papers in mathematical disciplines to be reduced to relatively small files that could be rendered client-side, allowing fully typeset scientific papers to be exchanged over the early Internet and emerging World Wide Web, even when sending large files was difficult.

A sample page produced using TeX with the LaTeX macros
Mathematical text typeset using TeX and the AMS Euler font
TeX Users Group's logo