Encyclopedia  |   World Factbook  |   World Flags  |   Reference Tables  |   List of Lists Academic Disciplines  |   Historical Timeline  |   Themed Timelines  |   Biographies  |   How-Tos
TeX
 Main Page | See live article | Alphabetical index

# TeX

]]

TEΧ, written as TeX in plain text, is a typesetting system written by Donald Knuth, which is popular in academia, especially in the mathematics, physics and computer science communities. It has largely displaced Unix troff, the other favored formatter, in many Unix installations.

(Pronunciation note: TeX derives from Greek technê, therefore the X (actually a capital chi) in TeX is pronounced like ch in German mich or German Technik. Alternatively it can be pronounced like ch in Scottish loch or simply like k. For help see [1].)

TeX is generally considered to be the best way to typeset complex mathematical formulas, but, especially in the form of LaTeX and other template packages, is now also being used for many other typesetting tasks. It can be used to compose mathematical expressions on Wikipedia pages; see Wikipedia:TeX markup.

 Table of contents 1 History 2 The typesetting system 3 License 4 Quality 5 The name 6 Derived works 7 Compatible tools 8 TeX and MediaWiki 9 Examples 10 See also 11 Application software for TeX 12 External links

## History

Knuth began to write TeX because he had become annoyed at the declining quality of the typesetting in volumes I-III of his monumental The Art of Computer Programming. In a manifestation of the typical hackish urge to solve the problem at hand once and for all, he began to design his own typesetting language. He thought he would finish it on his sabbatical in 1978; he was wrong by only about eight years. The language was finally frozen around 1985.

Guy Steele happened to be at Stanford during the summer of 1978, when Knuth was developing his first version of TeX. When he returned to MIT that fall, he rewrote TeX's I/O to run under ITS.

The first version of TeX was written in the SAIL programming language to run on a PDP-10 under Stanford's WAITS operating system. For later versions of TeX, Knuth invented the concept of literate programming, a way of producing compilable source code and high quality cross-linked documentation (typeset in TeX of course) from the same original file. The language used is called WEB and produces programs in Pascal.

TeX has an idiosyncratic version numbering system. Since version 3, updates have been indicated by adding an extra digit at the end of the decimal, so that the version number asymptotically approaches π. The current version is 3.14159. This is a reflection of the fact that TeX is now very stable, and only minor updates are anticipated. Knuth has stated that the "absolutely final change (to be made after my death)" will be to change the version number to π, at which point all remaining bugs will become features.

## The typesetting system

TeX commands commonly start with a backslash and are grouped with curly braces. However, almost all of TeX's syntactic properties can be changed on the fly which makes TeX input hard to parse by anything but TeX itself. 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 get executed. Expansion itself is practically side-effect free. Tail recursion of macros takes no memory, and if-then-else constructs are available. This makes TeX a Turing-complete language even at expansion level.

The TeX system has precise knowledge of the sizes of all characters and symbols, and using this information, it computes the optimal arrangement of letters per line and lines per page. It then produces a DVI file (for "device independent") containing the final locations of all characters. This dvi file can be printed directly given an appropriate printer driver, or it can be converted to other formats. Nowadays, PDFTeX is often used which bypasses DVI generation altogether.

Most functionality is provided by format files (predumped memory images of TeX after large macro collections have been loaded). Common formats are Knuth's original basic plain TeX, LaTeX (ubiquitous in the technical sciences), and ConTeXt (which is used primarily for Desktop Publishing).

The ultimate reference works for TeX are the first two volumes of Knuth's Computers and Typesetting, The TeXbook and TeX: The Program (which includes the complete documented source code for TeX).

The organisation of the directories in a TeX installation is standardized in a tree called texmf.

The license allows free distribution and modification but demands that any changed version not be called TEX, TeX, or anything confusingly similar, providing rights similar to those of a trademark.

## Quality

Though well-written, TeX is so large (and so full of cutting edge technique) that it is said to have unearthed at least one bug in every Pascal system it has been compiled with. TeX runs on almost all operating systems.

\\bye

renders as

### LaTeX examples

LaTeX is a collection of macros written in TeX. There are many predefined templates (with predefined styles) one can use. It is much more structured than TeX, providing a set of macros and utilities for indexing, tables, lists and so forth. For example:

\\documentclass[a4paper]{book}
\\begin{document}
\\section{ ... a title }
\\subsection{ ... a subtitle}
%% The text goes here
\\end{document}

To render the book as a PostScript file, use
 latex myfile.tex
dvips myfile.dvi

Alternatively, one way to render the book as a PDF file is
 pdflatex myfile.tex