What the heck is TeX?

TeX is the powerful typesetting language developed by Donald Knuth at Stanford University. TeX was originally conceived as a typesetting system for the creation of beautiful books that contained mathematics. Since that time, it has come to be embraced by the scientific and technical community as the typesetting language of choice.

If you want to know more, below is a short excerpt from The Advanced TeXbook by David Salomon. To learn even more, try the TeX FAQ.


TeX is not written TEX, it is not spelled 'T' 'E' 'X', and it is not pronounced "tex". It is written TeX [TEX] (a trademark of the AMS), it is spelled with the Greek letters Tau Epsilon Chi, and it is pronounced "tech" or rather "teck".

TeX is not a word processor. It is a program that sets text in lines and paragraphs---but its design philosophy, its methods, and its approach are all different from those of a word processor.

A modern, state-of-the-art word processor is a WYSIWYG-type program; TeX is not: It uses one-dimensional input to generate its two-dimensional output. With a word processor it is easy to generate special printing effects and easy to underline text, to italicize and emphasize; TeX can do those things---and with a lot more attention to detail---but the user has to work harder.

The same is true for applications that mix text with graphics. Good, modern word processors can also create diagrams, whereas TeX does not support graphics and some work is necessary to insert diagrams into its output. Other features that are standard and easy to use in a word processor are either nonexistent or hard to use with TeX.

If TeX is not a word processor, then what is it?

 

1.1 Basics

From the point of view of the user, TeX is a typesetting program that can be extended to a complete computerized typesetting system by adding a printer driver, the METAFONT program, and some utilities.

From the point of view of the computer, however, TeX is a compiler whose main task is to compile a source program. The source language has typed variables (called registers), block structure, two executable statements (assignment and if), and a powerful macro facility that makes it possible to extend the language. Looping is done by recursion. The main output of the compiler is a file containing not machine instructions, but detailed instructions on what characters to place on a page, and exactly where to place them.

When a compiler sees something in the source file which does not belong in the source language, it issues an error message. TeX, on the other hand, simply typesets any material in the source file that's not part of the language. The source file for TeX contains the test to be typeset, embedded commands and comments. It's a text file and can thus be prepared with any editor or word processor. TeX generates three outputs: a log file---with run-time information and error messages; terminal output (output considered important enough to be seen by the user immediately); and a .dvi file (for Device Independent), containing the page coordinates of each character to be typeset. A separate printer driver program later reads the .dvi file and generates printer commands (which are different for different printers) to print the text. Most TeX implementations also include a screen preview program that makes it possible to view the typeset pages before they go on paper.

Two font files must exist for each font used in the text, a .tfm file and a bitmap file (usually called .gf or .pk file). The .tfm file (for TeX Font Metric) contains the dimensions of each character in the font (width, height, and depth) and some other information. The bitmap file contains the actual shape of the characters. TeX uses only the .tfm file. When the position of a character on the page is determined, TeX uses the character's width to move the reference point to where the next character should appear. As a result, TeX is ignorant of the actual shape of the characters, and its final output is a list of commands that specify what should be placed on the page and where. A typical command is a triplet of the form:

The bitmap file is only used by the printer driver, which sends the individual pixels of each character to the printer.

[Figure omitted]

To come back to the point of view of the user, the main aim of TeX is to produce beautifully typeset documents, especially documents containing mathematics. As a result, TeX is ideal for book publishing, for documents that should look beautiful---such as concert programs and invitations---and for technical publishing. Since typesetting is not a simple process (it is in fact very complex, especially the typesetting of tables and mathematics), TeX is not easy to use. It has several features that are complex and hard to master. As a result, new users tend to use TeX only if they need high-quality output. When such users need a quick letter, a simple memo, or a short note, they may go back to their familiar word processor. However, advanced users usually have macros that help produce all kinds of documents easily, thus using TeX's power all the time. Either way, if you like beautiful text, or if you write mathematics, TeX is by far the best typesetting tool available today.


Pages 1-3 of The Advanced TeXbook by David Salomon.