TeX |
TEX, written as TeX in plain text, is a typesetting system Computer programming by Donald Knuth. It is popular in academia, especially in the mathematics, Physics and computer science community. It has largely displaced Unix Troff, the other favored formatter, in many Unix installations.
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.
=The name and its pronunciation(s)=
A homage to Caltech, where Knuth received his doctorate, the name TeX is intended to be pronounced tekh , where kh represents the sound at the end of Scottish English loch or the name of the German composer Johann Sebastian Bach (in International Phonetic Alphabet ). The X is meant to represent the Greek alphabet letter χ (chi (letter)). TeX is the abbreviation of τέχνη (technē), Greek for art and craft , which is also the source word of technical . English speakers often pronounce it tek , like the first syllable of technology .
The name is properly typeset with the E below the baseline; systems that do not support subscript layout use the approximation TeX . Fans like to proliferate names from the word TeX — such as TeXnician (user of TeX software), TeXpert, TeXhacker (TeX programmer), TeXmaster (competent TeX programmer), TeXhax, and TeXnique.
=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, but the language was not frozen until 1989, more than ten years later.
Guy Steele happened to be at Stanford during the summer of 1978, when Knuth was developing his first version of TeX. When Steele returned to Massachusetts Institute of Technology that fall, he rewrote TeX s I/O to run under Incompatible Timesharing System.
The first version of TeX was written in the SAIL programming language to run on a PDP-10 under Stanford University 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 programming language.
TeX has an idiosyncratic software version. Since version 3, updates have been indicated by adding an extra digit at the end of the decimal, so that the version number asymptote approaches pi. The current version is 3.141592. 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 language even at expansion level.
The system can roughly be divided in four levels: in the first characters are read from file and assigned a category code. Combinations of a backslash (really: any character of category zero) followed by letters (characters of category 11) or a single other character are replaced by a control sequence token. In this sense this stage is like lexical analysis, although it does not form numbers from digits. In the next stage, expandable control sequences (such as conditionals or defined macros) are replaced by their replacement text. The input for the third stage is then a stream of characters, including ones with special meaning, and unexpandable control sequences, typically assignments and visual commands. Here characters get assembled into a paragraph. TeX s paragraph breaking algorithm works by optimizing breakpoints over the whole paragraph. After the paragraph is broken into lines, the vertical list of lines and other material is broken into pages.
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 (TeX) 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).
TeX is usually distributed together with METAFONT, a companion program also developed by Knuth which allows algorithmic description of fonts. The organisation of the directories in a TeX / Metafont installation is standardized in a tree called texmf .
=License=
The license allows free distribution and modification, but demands that any changed versions must not be called TEX, TeX, or anything confusingly similar. The American Mathematical Society has registered a trademark for TEX. A test suite called the TRIP test has been made to help testing whether an implementation is really a TEX.
=Quality=
TeX is written in WEB, a mixture of documentation written in TeX and a quite restricted Pascal subset. For example, TeX does all of its dynamic allocation itself from fixed-size arrays. As a result, TeX has been ported to almost all operating systems (usually by using the web2c converter).
Knuth offers knuth reward check to people who find and report a computer bug in it. The award per bug started at $2.56 and doubled every year until it was frozen at its current value of $327.68. This has not made Knuth poor, however, as there have been very few bugs and in any case a cheque proving that the owner found a bug in TeX is usually framed instead of cashed.
= Computer-science aspects of TeX =
The TeX software incorporates several interesting algorithms, and has led to a number of theses of Knuth s students. For instance, a hyphenation algorithm (work by Frank Liang) is used that assigns priorities to breakpoints in letter groups. A list of hyphenation patterns can be generated automatically from a corpus of hyphenated words.
The line breaking algorithm is an example of dynamic programming. The problem of breaking a paragraph of n words into lines has a naive complexity of 2n, but with dynamic programming a globally optimal layout can be derived in time proportional to the number of words and the number of words per line. A thesis by Michael Plass shows how the page breaking problem can be NP-complete because of the added complication of placing figures.
The companion program METAFONT for character generation uses Bezier curves in a fairly standard way, but Knuth devotes lots of attention to the rasterizing problem on bitmapped displays. Another thesis, by John Hobby, further explores this problem of digitizing brush trajectories . This term derives from the fact that Metafont describes characters as having been drawn by abstract brushes. While TeX has been highly successful, Metafont has not been accepted by professional type designers, and fonts produced with it like Computer Modern have been harshly criticized.
= Derived works =
Several document processing systems are based on TeX, notably:
= Compatible tools =
On , there is the [http://www.miktex.org/ MiKTeX] distribution and the [http://www.fptex.org/ fpTeX] distribution.
The TeXmacs text editor is a WYSIWYG scientific text editor that is intended to be compatible with TeX. It uses Knuth s fonts, and can generate TeX output. LyX for UNIX, TeXShop for Mac OS X, and WinShell for Microsoft Windows are similar tools.
The KDE windowing system for Unix has a program, Kile, for editing LaTeX and TeX.
GNU Emacs has various built-in and third party packages with support for TeX, the major one being AUCTeX.
= Examples =
A simple plain TeX example - Create a text file myfile.tex with the following content: hello ye
Then open a command line interpreter and type tex myfile.tex
TeX then creates a file myfile.dvi Use a viewer to look at the file. MikTeX for example contains a viewer called Yap (computer program): yap myfile.dvi
The viewer shows hello on a page. ye is a TeX command which marks the end of the file and is not shown in the final output.
The dvi file can either be printed directly from the viewer or converted to a more common format such as PostScript using the Dvips program.
Alternatively Portable Document Format files may be created directly, using PdfTeX: pdftex myfile.tex
pdfTeX was originally created because converting generated PostScript into PDF resulted in poor font display, though printing performance was fine. This was because TeX natively uses bitmap fonts, which are only designed to display well at one particular size, whereas PostScript typically uses scalable Type 1 fonts.
It is now possible to make dvips output scalable fonts with a bit of tweaking (newer versions of Ghostscript support it), but direct conversion to PDF has other benefits: it is a one-step, not two-step process, and pdfTeX provides facilities such as bookmarks and hyperlinks not found in PostScript.
== Mathematical examples ==
To see TeX further in action, look at its formatting of mathematical formulas. For example, to write the well-known quadratic formula, try entering The quadratic formula is ${-bpmsqrt{b^2-4ac} over {2a}}$ ye
Use TeX as above, and you should get something that looks like :The quadratic formula is {-bpmsqrt{b^2-4ac} over {2a}}
Notice how the formula is printed in a way a person would write by hand, or typeset the equation. In a document, entering mathematics mode is done by starting with a $, then entering a formula in TeX semantics and closing again with another $. Display mathematics, or mathematics presented centered on a new line is done by using $$. For example, the above with the quadratic formula in display math:
The quadratic formula is $${-bpmsqrt{b^2-4ac} over {2a}}$$ ye
renders as :The quadratic formula is {-bpmsqrt{b^2-4ac} over {2a}}
== 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} egin{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
=References=
=See also=
*METAFONT *MetaPost *List of document markup languages *Comparison of document markup languages *TeX Users Group *Texvc, TeX preprocessor used in MediaWiki *PSTricks, a PostScript set of macros.
=External links=
*[http://refcards.com/refcards/tex/tex-refcard-letter.pdf Plain TeX Quick Reference (PDF)]
==Software==
==Periodicals==
|
|