TeX

(Redirected from TeX markup)

Developer(s) Donald Knuth 1978; 40 years ago 3.14159265 / January 2014; 4 years ago WEB/Pascal Cross-platform Typesetting Permissive free software tug.org
Filename extension .tex application/x-tex 1978; 40 years ago Document file format

TeX (/tɛx, tɛk/, see below), stylized within the system as TeX, is a typesetting system (or "formatting system") designed and mostly written by Donald Knuth[1] and released in 1978. Together with the Metafont language for font description and the Computer Modern family of typefaces, TeX was designed with two main goals in mind: to allow anybody to produce high-quality books using minimal effort, and to provide a system that would give exactly the same results on all computers, at any point in time.[2] TeX is free software, which made it accessible to a wide range of users.

TeX is a popular means of typesetting complex mathematical formulae; it has been noted as one of the most sophisticated digital typographical systems.[3] TeX is popular in academia, especially in mathematics, computer science, economics, engineering, linguistics, physics, statistics, and quantitative psychology. It has largely displaced Unix troff, the other favored formatting system, in many Unix installations, which use both for different purposes. It is also used for many other typesetting tasks, especially in the form of LaTeX, ConTeXt, and other macro packages.

History

When the first paper volume of Donald Knuth's The Art of Computer Programming was published in 1968,[4] it was typeset using hot metal typesetting set by a Monotype machine. This method, dating back to the 19th century, produced a "classic style" appreciated by Knuth.[5]

When the second edition of the second volume 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. When Knuth received the galley proofs of the new book on 30 March 1977, he found them inferior.[5] Around that time, Knuth saw for the first time the output of a high-quality digital typesetting system, and became interested in digital typography. Disappointed by the galley proofs, he was motivated to design his own typesetting system. On 13 May 1977, he wrote a memo to himself describing the basic features of TeX.[6]

He planned to finish it on his sabbatical in 1978, but as it happened the language was not "frozen" (ready to use) 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 the Massachusetts Institute of Technology that autumn, he rewrote TeX's input/output (I/O) to run under the Incompatible Timesharing System (ITS) operating system. 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 cross-linked documentation typeset in TeX from the same original file. The language used is called WEB and produces programs in DEC PDP-10 Pascal.

A new version of TeX, rewritten from scratch and called TeX82, was published in 1982. Among other changes, the original hyphenation algorithm was replaced by a new algorithm written by Frank Liang. TeX82 also uses fixed-point arithmetic instead of floating-point, to ensure reproducibility of the results across different computer hardware,[7] and includes a real, Turing-complete programming language, following intense lobbying by Guy Steele.[8] In 1989, Donald Knuth released new versions of TeX and Metafont.[9] Despite his desire to keep the program stable, Knuth realised that 128 different characters for the text input were not enough to accommodate foreign languages; the main change in version 3.0 of TeX is thus the ability to work with 8-bit inputs, allowing 256 different characters in the text input.

Since version 3, TeX has used an idiosyncratic version numbering system, where updates have been indicated by adding an extra digit at the end of the decimal, so that the version number asymptotically approaches π. This is a reflection of the fact that TeX is now very stable, and only minor updates are anticipated. The current version of TeX is 3.14159265; it was last updated 2014-01-12.[10] The design was frozen after version 3.0, and no new feature or fundamental change will be added, so all newer versions will contain only bug fixes. 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. For this reason, he 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.[11] Likewise, versions of METAFONT after 2.0 asymptotically approach e, and a similar change will be applied after Knuth's death.

Since the source code of TeX is essentially in the public domain (see below), other programmers are allowed (and explicitly encouraged) to improve the system, but are required to use another name to distribute the modified TeX, meaning that the source code can still evolve. For example, the Omega project was developed after 1991, primarily to enhance TeX's multilingual typesetting abilities. 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.[12]

Typesetting system

TeX commands commonly start with a backslash and are grouped with curly braces. 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 are then executed. Expansion itself is practically free from side effects. Tail recursion of macros takes no memory, and if-then-else constructs are available. This makes TeX a Turing-complete language even at the expansion level.[13] 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). Combinations of a backslash (actually, 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. The fourth stage breaks the vertical list of lines and other material 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 file ("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. The base TeX system understands about 300 commands, called primitives.[14] 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). Knuth's original default format, which adds about 600 commands, is Plain TeX.[15] 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. Most of the features of AMS-TeX can be used in LaTeX by using the AMS "packages". This is then referred to as AMS-LaTeX. Other formats include ConTeXt, used primarily for desktop publishing and written mostly by Hans Hagen at Pragma.

How it is run

A sample page produced using TeX with the LaTeX macros

A sample Hello world program in plain TeX is:

Hello, World
\bye          % marks the end of the file; not shown in the final output


This might be in a file myfile.tex, as .tex is a common file extension for plain TeX files. By default, everything that follows a percent sign on a line is a comment, ignored by TeX. Running TeX on this file (for example, by typing tex myfile.tex in a command-line interpreter, or by calling it from a graphical user interface) will create an output file called myfile.dvi, representing the content of the page in a device independent format (DVI). A DVI file could then either be viewed on screen or converted to a suitable format for any of the various printers for which a device driver existed (printer support was generally not an operating system feature at the time that TeX was created). Knuth has said that there is nothing inherent in TeX that requires DVI as the output format, and later versions of TeX, notably pdfTeX, XeTeX and LuaTeX, all support output directly to PDF.

Mathematical example

TeX provides a different text syntax specifically for mathematical formulas. For example, the quadratic formula (which is the solution of the quadratic equation) appears as:

Markup Renders as
The quadratic formula is $-b \pm \sqrt{b^2 - 4ac} \over 2a$
\bye


${\displaystyle {\hbox{The quadratic formula is }}\textstyle {-b\pm {\sqrt {b^{2}-4ac}} \over 2a}}$

Distributions and extensions

TeX is usually provided in the form of an easy-to-install bundle of TeX itself along with Metafont and all the necessary fonts, documents formats, and utilities needed to use the typesetting system. On UNIX-compatible systems, including GNU/Linux and Apple macOS, TeX is distributed as part of the larger TeX Live distribution. (Prior to TeX Live, the teTeX distribution was the de facto standard on UNIX-compatible systems.) On Microsoft Windows, there is the MiKTeX distribution (enhanced by proTeXt) and the Microsoft Windows version of TeX Live.

Several document processing systems are based on TeX, notably jadeTeX, which uses TeX as a backend for printing from James Clark's DSSSL Engine, the Arbortext publishing system, and Texinfo, the GNU documentation processing system. TeX has been the official typesetting package for the GNU operating system since 1984.

Numerous extensions and companion programs for TeX exist, among them BibTeX for bibliographies (distributed with LaTeX), pdfTeX, a TeX-compatible engine which bypasses dvi and produces output in Adobe Systems's Portable Document Format, XeTeX, an TeX-compatible engine that supports Unicode and OpenType, and LuaTeX, an Unicode-aware extension to TeX that includes a Lua runtime with extensive hooks into the underlying TeX routines and algorithms. Most TeX extensions are available for free from CTAN, the Comprehensive TeX Archive Network.

Editors

There are a variety of editors designed to work with TeX:

1. The TeXmacs text editor is a WYSIWYW scientific text editor, inspired by both TeX and Emacs. It uses Knuth's fonts and can generate TeX output.
2. LyX is a WYSIWYM document processor which runs on a variety of platforms including:
1. GNU/Linux,
2. Microsoft Windows (newer versions require Windows 2000 or later)
3. Apple Mac OS X (using a non-native Qt front-end).
3. TeXShop (for Mac OS X), TeXworks (for GNU/Linux, Mac OS X and Windows) and WinShell (for Windows) are similar tools and provide an integrated development environment (IDE) for working with LaTeX or TeX. For KDE/Qt, Kile provides such an IDE.
4. Texmaker is the Pure Qt equivalent of Kile, with a user interface that is nearly the same as Kile's.
5. TeXstudio is an open-source fork (2009) of Texmaker that offers a different approach to configurability and features. Free downloadable binaries are provided for Windows, Linux, Mac OS X, OS/2, and FreeBSD.
6. GNU Emacs has various built-in and third-party packages with support for TeX, the major one being AUCTeX.
7. For Vim, possible plugins include Vim-LaTeX Suite,[38] Automatic TeX[39] and TeX-9.[40]
8. For Google Docs, Auto-Latex Equations is a Google Docs add-on that provides mathematical TeX typesetting (MathJax supported).

Donald Knuth has indicated several times[41][42][43] that the source code of TeX has been placed into the "public domain", and he strongly encourages modifications or experimentations with this source code. In particular, since Knuth highly values the reproducibility of the output of all versions of TeX, any changed version must not be called TeX, or anything confusingly similar. To enforce this rule, any implementation of the system must pass a test suite called the TRIP test[44] before being allowed to be called TeX. The question of license is somewhat confused by the statements included at the beginning of the TeX source code,[45] which indicate that "all rights are reserved. Copying of this file is authorized only if ... you make absolutely no changes to your copy". This restriction should be interpreted as a prohibition to change the source code as long as the file is called tex.web. 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'").[46] The American Mathematical Society tried in the early 1980s to claim a trademark for TeX. This was rejected because at the time "TEX" (all caps) was registered by Honeywell for the "Text EXecutive" text processing system.[citation needed]

Use of TeX

In several technical fields, in particular, computer science, mathematics, engineering, and physics, TeX has become a de facto standard. Many thousands of books have been published using TeX, including books published by Addison-Wesley, Cambridge University Press, Elsevier, Oxford University Press and Springer. Numerous journals in these fields are produced using TeX or LaTeX, allowing authors to submit their raw manuscript written in TeX.[47] While many publications in other fields, including dictionaries and legal publications, have been produced using TeX, it has not been as successful as in more technical fields, because TeX was primarily designed for mathematics. When he designed TeX, Donald Knuth did not believe that a single typesetting system would fit everyone's needs; instead, he designed many hooks inside the program so that it would be possible to write extensions, and released the source code, hoping that publishers would design versions tailored to their needs. While such extensions have been created (including some by Knuth himself[48]), most people have extended TeX only using macros and it has remained a system associated with technical typesetting.[49][50]

It is possible to use TeX for automatic generation of sophisticated layout for XML data. The differences in syntax between the two description languages can be overcome with the help of TeXML. In the context of XML publication, TeX can thus be considered an alternative to XSL-FO. 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. This paved the way for the creation of repositories of scientific papers such as arXiv, through which papers could be 'published' without an intermediary publisher.[51]

TeX formulas may be inserted in MediaWiki pages using the [itex] tag.

Pronunciation and spelling

The name TeX is intended by its developer to be /tɛx/, with the final consonant of loch or Bach.[52] The letters of the name are meant to represent the capital Greek letters tau, epsilon, and chi, as TeX is an abbreviation of τέχνη (ΤΕΧΝΗ – technē), Greek for both "art" and "craft", which is also the root word of technical. English speakers often pronounce it /ˈtɛk/, like the first syllable of technical. Knuth instructs that it be typeset with the "E" below the baseline and reduced spacing between the letters. This is done, as Knuth mentions in his TeXbook, to distinguish TeX from other system names such as TEX, the Text EXecutive processor (developed by Honeywell Information Systems).[53] Fans like to proliferate names from the word "TeX"—such as TeXnician (user of TeX software), TeXhacker (TeX programmer), TeXmaster (competent TeX programmer), TeXhax, and TeXnique.[54]

Community

TeX Users Group's logo

Notable entities in the TeX community include the TeX Users Group, which publishes TUGboat and The PracTeX Journal, covering a wide range of topics in digital typography relevant to TeX. The Deutschsprachige Anwendervereinigung TeX is a large user group in Germany. The TeX Users Group was founded in 1980 for educational and scientific purposes, provides an organization for those who have an interest in typography and font design, and are users of the TeX typesetting system invented by Donald Knuth. The TeX Users Group represents the interests of TeX users worldwide. The TeX Users Group publishes the journal TUGboat three times per year. tex.stackexchange.com is an active question and answer site for new and experienced TeX users alike.

References

1. ^ "Per Bothner (assistant of Knuth) discusses authorship". Knuth definitely wrote most of the code himself, at least for the Metafont re-write, for which I have pe[r]sonal knowledge. However, some of his students (such as Michael Plass and John Hobby) did work on the algorithms used in TeX and Metafont.
2. ^ Gaudeul, Alexia (27 March 2006). "Do Open Source Developers Respond to Competition?: The (La)TeX Case Study". SSRN 908946.
3. ^ Yannis Haralambous. Fonts & Encodings (Translated by P. Scott Horne). Beijing; Sebastopol, Calif: O’Reilly Media, 2007, pp. 235.
4. ^ Knuth, Donald E. "Less brief biography". Don Knuth's Home Page. Retrieved 9 January 2017.
5. ^ a b Knuth, Donald. "Commemorative lecture of the Kyoto Prize, 1996" (PDF). Kyoto Prize. Retrieved 18 August 2018.
6. ^ Knuth, Donald Ervin, TEXDR.AFT
7. ^ Knuth and Plass, p. 144
8. ^ Donald E. Knuth, Knuth meets NTG members, NTG: MAPS. 16 (1996), 38–49. Reprinted as Questions and Answers, III, chapter 33 of Digital Typography, p. 648.
9. ^ Donald E. Knuth. The New Versions of TeX and METAFONT, TUGboat 10 (1989), 325–328; 11 (1990), 12. Reprinted as chapter 29 of Digital Typography.
10. ^ "TeX 14 release". Retrieved 20 January 2014.
11. ^ Donald E. Knuth. The future of TeX and METAFONT, NTG journal MAPS (1990), 489. Reprinted as chapter 30 of Digital Typography, p. 571.
12. ^ Donald E. Knuth and Pierre MacKay. Mixing Right-to-Left Texts with Left-to-Right Texts, TUGboat 8 (1987), 14–25. Reprinted as chapter 4 of Digital Typography.
13. ^ Jeffrey, Alan (1990), "Lists in TeX's Mouth" (PDF), TUGboat, 11 (2): 237–45
14. ^ Knuth 1984, p. 9.
15. ^ Plain TeX (source code), CTAN
16. ^ Knuth 1984, p. 127, Ch. 16: Typing Math Formulas.
17. ^ Slater, Robert (1989), Portraits in Silicon, MIT Press, p. 349, ISBN 9780262691314
18. ^ Syropoulos, Apostolos; Tsolomitis, Antonis; Sofroniou, Nick (2003), Digital Typography Using LaTeX, Springer, p. 93, ISBN 9780387952178
19. ^ Donald E. Knuth. Questions and Answers II, TUGboat 17 (1996), pp. 355–367. Reprinted as chapter 32 of Digital Typography, pp. 620–624.
20. ^ Donald E. Knuth. Typesetting Concrete Mathematics, TUGboat 10 (1989), pp. 31–36, 342. Reprinted as chapter 18 of Digital Typography, pp. 367–378.
21. ^ Ulrik Vieth (2001) Math typesetting in TEX: The good, the bad, the ugly
22. ^
23. ^
24. ^ "Map" (PDF). www.ntg.nl.
25. ^ Barnett, Michael P (1965), Computer Typesetting: Experiments and Prospects, Cambridge, MA: MIT Press
26. ^
27. ^ "Donald E. Knuth" (PDF), TUGboat (interview), Advogato, 21: 103–10, 2000
28. ^ "4.1 fmt: Reformat paragraph text", Core GNU utilities (GNU coreutils) manual, GNU Project, 2016
29. ^ Liang 1983, p. 3.
30. ^
31. ^ "Appendix H: Hyphenation", The TeXbook, pp. 449–55
32. ^ Donald E. Knuth, List of updates to the TeX82 listing published in September 1982, available on CTAN.
33. ^ Donald E. Knuth, Appendix to the Errors of TeX paper, available on CTAN, last modified in January 2003.
34. ^ "Frequently Asked Questions". sunburn.stanford.edu/~knuth/. Archived from the original on 10 February 2012.
35. ^ Kara Platoni, Love at First Byte. Stanford Magazine, May–June 2006
36. ^
37. ^ "Knuth: Recent News". www-cs-faculty.stanford.edu.
38. ^ Vim‐LaTex, Source forge
39. ^ Automatic TeX plugin, Launch pad
40. ^ TeX-9, Vim.org
41. ^ "The future of TeX and METAFONT", Digital Typography, p. 572
42. ^ Knuth, Donald E (1986), "Computers and Typesettings" (PDF), TUGboat, 7: 95–98
43. ^ "Chapter 28", Digital Typography (PDF), p. 560
44. ^ "Trip", CTAN (TeX) (source code)
45. ^
46. ^ Open Source: Technology and Policy by Fadi P. Deek, James A. M. McHugh "Public domain", page 227 (2008)
47. ^ Beebe, p. 10.
48. ^ Knuth, Donald Ervin; MacKay, Pierre (1987), "Mixing Right-to-Left Texts with Left-to-Right Texts" (PDF), TUGboat, 8: 14–25. Reprinted as "Chapter 4", Digital Typography
49. ^ Knuth, Donald Ervin (1996), "Questions and Answers I", TUGboat, 17: 7–22. Reprinted as "Chapter 31", Digital Typography, p. 598
50. ^ Knuth, Donald Ervin (1996), "Questions and Answers II", TUGboat, 17: 355–67. Reprinted as "Chapter 32", Digital Typography, pp. 616–17
51. ^ O'Connell, Heath (2000). "Physicists Thriving with Paperless Publishing". arXiv:physics/0007040.
52. ^ Donald E. Knuth, The TeXbook, Ch. 1: The Name of the Game, p. 1.
53. ^ Donald E. Knuth. The TeX Logo in Various Fonts, TUGboat 7 (1986), 101. Reprinted as chapter 6 of Digital Typography.
54. ^ "The Jargon File—TeX". Retrieved 23 July 2016.