TeX
TeX | |
---|---|
![]() | |
Developer(s) | Donald Knuth |
Initial release | 1978 |
Stable release | TeX Live 2024[1]
/ 13 March 2024 |
Repository | |
Written in | Permissive free software |
Website | tug |
TeX | |
---|---|
Filename extension |
.tex |
Internet media type | |
Initial release | 1978 |
Type of format | Document file format |
TeX (
TeX is widely used in
TeX was designed with two main goals in mind: to allow anybody to produce high-quality books with minimal effort, and to provide a system that would give exactly the same results on all computers, at any point in time (together with the Metafont language for font description and the Computer Modern family of typefaces).[4] TeX is free software, which made it accessible to a wide range of users.
History
When the first paper volume of Knuth's The Art of Computer Programming was published in 1968,[5] it was typeset using hot metal typesetting on a Monotype machine. This method, dating back to the 19th century, produced a "classic style" appreciated by Knuth.[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. When Knuth received the galley proofs of the new book on 30 March 1977, he found them inferior. Disappointed, Knuth set out to design his own typesetting system.
Knuth saw for the first time the output of a high-quality digital typesetting system, and became interested in digital typography. On 13 May 1977, he wrote a memo to himself describing the basic features of TeX.
For later versions of TeX, Knuth invented the concept of
TeX82, a new version of TeX rewritten from scratch, was published in 1982. Among other changes, the original
Since version 3, TeX has used an idiosyncratic
Pronunciation and spelling
The name TeX is intended by its developer to be pronounced
Syntax
TeX commands commonly start with a
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
amsmath
, amssymb
) and the "AMS document classes" (e.g., amsart
, amsbook
). This is then referred to as AMS-LaTeX.[22] Other formats include ConTeXt, used primarily for desktop publishing and written mostly by Hans Hagen at PragmaDesign
The TeX software incorporates several aspects that were not available, or were of lower quality, in other typesetting programs at the time when TeX was released. Some of the innovations are based on interesting algorithms, and have led to several theses for Knuth's students. While some of these discoveries have now been incorporated into other typesetting programs, others, such as the rules for mathematical spacing, are still unique.
Mathematical spacing

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.[23][24] He took three bodies of work that he considered to be standards of excellence for mathematical typography: the books typeset by the Addison-Wesley Publishing house (the publisher of The Art of Computer Programming) under the supervision of Hans Wolf; editions of the mathematical journal Acta Mathematica dating from around 1910; and a copy of Indagationes Mathematicae, a Dutch mathematics journal. Knuth looked closely at these printed papers to sort out and look for a set of rules for spacing.[25][26] 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. For example, the spacing for Knuth's Computer Modern fonts has been precisely fine-tuned over the years and is now set; but when other fonts, such as AMS Euler, were used by Knuth for the first time, new spacing parameters had to be defined.[27]
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. This resulted in some "hacks" overloading some fields, which in turn required other "hacks". On an aesthetics level, the rendering of radicals has also been criticized.
Hyphenation and justification
In comparison with manual typesetting, the problem of
Formally, the algorithm defines a value called badness associated with each possible line break; the badness is increased if the spaces on the line must stretch or shrink too much to make the line the correct width. Penalties are added if a breakpoint is particularly undesirable: for example, if a word must be hyphenated, if two lines in a row are hyphenated, or if a very loose line is immediately followed by a very tight line. The algorithm will then find the breakpoints that will minimize the sum of squares of the badness (including penalties) of the resulting lines. If the paragraph contains possible breakpoints, the number of situations that must be evaluated naively is . However, by using the method of dynamic programming, the complexity of the algorithm can be brought down to (see Big O notation). 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 , where is the width of a line. A similar algorithm is used to determine the best way to break paragraphs across two pages, in order to avoid
If no suitable line break can be found for a line, the system will try to hyphenate a word. 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
Metafont
Metafont, not strictly part of TeX, is a font description system which allows the designer to describe characters algorithmically. It uses Bézier curves in a fairly standard way to generate the actual characters to be displayed, but Knuth devotes substantial 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 (and erasers). It is commonly believed that TeX is based on bitmap fonts but, in fact, these programs "know" nothing about the fonts that they are using other than their dimensions. It is the responsibility of the device driver to appropriately handle fonts of other types, including PostScript Type 1 and TrueType. Computer Modern (commonly known as "the TeX font") is freely available in Type 1 format, as are the AMS math fonts. Users of TeX systems that output directly to PDF, such as pdfTeX, XeTeX, or LuaTeX, generally never use Metafont output at all.
Macro language
TeX documents are written and programmed using an unusual macro language. Broadly speaking, the running of this macro language involves expansion and execution stages which do not interact directly. Expansion includes both literal expansion of macro definitions as well as conditional branching, and execution involves such tasks as setting variables/registers and the actual typesetting process of adding glyphs to boxes.
The definition of a macro not only includes a list of commands but also the syntax of the call. It differs with most widely used
The TeX macro language has been used to write larger document production systems, most notably including LaTeX and ConTeXt.
Operation

A sample
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
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:
Source code | Renders as |
---|---|
The quadratic formula is $-b \pm \sqrt{b^2 - 4ac} \over 2a$
\bye
|
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 $ symbol, then entering a formula in TeX syntax, and closing again with another of the same symbol. Knuth explained in jest that he chose the dollar sign to indicate the beginning and end of mathematical mode in plain TeX because typesetting mathematics was traditionally supposed to be expensive.[40] Display mathematics (mathematics presented centred on a new line) is similar but uses $$ instead of a single $ symbol. For example, the above with the quadratic formula in display math:
Source code | Renders as |
---|---|
The quadratic formula is $$-b \pm \sqrt{b^2 - 4ac} \over 2a$$
\bye
|
Uses
In several technical fields such as 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.[41] While many publications in other fields, including dictionaries and legal publications, have been produced using TeX, it has not been as successful as in the more technical fields, as TeX was primarily designed to typeset 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 the publishers would design versions tailoring to their own needs. While such extensions have been created (including some by Knuth himself),[42] most people have extended TeX only using macros and it has remained a system associated with technical typesetting.[43][44][26]
Chemistry notation
Packages like mhchem, XyMTeX, chemfig, and chemmacros for typesetting chemical equations, structures, and reactions in LaTeX.[45]
XML publication
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.[46]
Development
The original source code for the current TeX software is written in
Due to scammers finding scanned copies of his checks on the internet and using them to try to drain his bank account, Knuth no longer sends out real checks, but those who submit bug reports can get credit at The Bank of San Serriffe instead.[52]
Distributions and extensions
TeX is usually provided in the form of an easy-to-install bundle of TeX itself along with
Several document processing systems are based on TeX, notably
Numerous extensions and companion programs for TeX exist, among them BibTeX for bibliographies (distributed with LaTeX); pdfTeX, a TeX-compatible engine which can directly produce PDF output (as well as continuing to support the original DVI output); XeTeX, a TeX-compatible engine that supports Unicode and OpenType; and LuaTeX, a 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.
License
Donald Knuth has indicated several times[53][54][55][26] that the source code of TeX has been placed into the "public domain", and he strongly encourages modifications or experimentations with this source code. However, 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[56] before being allowed to be called TeX. The question of licence is somewhat confused by the statements included at the beginning of the TeX source code,[57] 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. The copyright note at the beginning of tex.web (and mf.web) was changed in 2021 to explicitly state this. 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'").[58] 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]
Since the source code of TeX is essentially in the
Community

Notable entities in the TeX community include the TeX Users Group (TUG), which currently publishes
Editors
There are a variety of editors designed to work with TeX:
- The TeXmacs text editor is a WYSIWYG-WYSIWYM scientific text editor, inspired by both TeX and Emacs. It uses Knuth's fonts and can generate TeX output.
- Overleaf is a partial-WYSIWYG, online editor that provides a cloud-based solution to TeX along with additional features in real-time collaborative editing.
- LyX is a WYSIWYM document processor which runs on a variety of platforms including:
- Linux,
- Microsoft Windows (newer versions require Windows 2000 or later)
- Apple Qtfront-end).
- TeXShop (for macOS), TeXworks (for Linux, macOS 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.
- Texmaker is the Pure Qt equivalent of Kile, with a user interface that is nearly the same as Kile's.
- 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, macOS, OS/2, and FreeBSD.
- GNU Emacs has various built-in and third-party packages with support for TeX, the major one being AUCTeX.
- Visual Studio Code. A notable extension is LaTeX Workshop
- For Vim, possible plugins include Vim-LaTeX Suite,[62] Automatic TeX,[63] and TeX-9.[64]
- For Apache OpenOffice and LibreOffice, iMath and TexMaths extensions can provide mathematical TeX typesetting.[65][66]
- For MediaWiki, the Math extension provides mathematical TeX typesetting, but the code needs to be surrounded by
<math>
tag.
Extensions
See also
- Comparison of document markup languages
- Formula editor – Computer program used to typeset mathematical works or formulae
- List of document markup languages
- MathJax – Cross-browser JavaScript library that displays mathematical equations in web browsers
- MathTime – Typeface for TeX
- New Typesetting System
- PGF/TikZ – Graphics languages
- PSTricks
- xdvi – Open Source Computer Program
Notes
- ^ "TeX Live - TeX Users Group". tug.org. Retrieved 25 April 2024.
- ^ "Per Bothner (attendee at TeX Project meetings) 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.
- ^ Yannis Haralambous. Fonts & Encodings (Translated by P. Scott Horne). Beijing; Sebastopol, Calif: O'Reilly Media, 2007, pp. 235.
- ISSN 1556-5068.
- ^ Knuth, Donald E. "Less brief biography". Don Knuth's Home Page. Archived from the original on 5 December 2016. Retrieved 9 January 2017.
- ^ Knuth, Donald E. "Commemorative lecture of the Kyoto Prize, 1996" (PDF). Kyoto Prize. Archived from the original (PDF) on 27 January 2018. Retrieved 18 August 2018.
- ^ Knuth, Donald Ervin, TEXDR.AFT, archived from the original on 12 January 2015
- ^ This article is based on material taken from TeX at the Free On-line Dictionary of Computing prior to 1 November 2008 and incorporated under the "relicensing" terms of the GFDL, version 1.3 or later.
- ^ Knuth & Plass 1981, p. 144.
- ^ Knuth, Donald E. Knuth meets NTG members, NTG: MAPS. 16 (1996), 38–49. Reprinted as Questions and Answers, III, chapter 33 of Digital Typography, p. 648.
- ^ Knuth, Donald E. The New Versions of TeX and METAFONT, TUGboat 10 (1989), 325–328; 11 (1990), 12. Reprinted as chapter 29 of Digital Typography.
- ISBN 978-0-19-509686-6.
- ^ "TeX 21 release". Retrieved 5 January 2022.
- ^ a b "What is the future of TeX?". The TeX FAQ. 27 May 2018. Archived from the original on 28 April 2019. Retrieved 21 July 2019.
- ^ Knuth, Donald E. The future of TeX and METAFONT, NTG journal MAPS (1990), 489. Reprinted as chapter 30 of Digital Typography, p. 571.
- ^ Knuth, Donald E. The TeXbook, Ch. 1: The Name of the Game, p. 1.
- ^ Knuth, Donald E. The TeX Logo in Various Fonts, TUGboat 7 (1986), 101. Reprinted as chapter 6 of Digital Typography.
- ^ Jeffrey, Alan (1990), "Lists in TeX's Mouth" (PDF), TUGboat, 11 (2): 237–45
- ^ "CTAN: Package pdftex". ctan.org. Retrieved 21 July 2019.
- ^ Knuth 1984, p. 9.
- ^ Plain TeX (source code), CTAN, archived from the original on 9 May 2021
- ^ "What are the AMS packages (amsmath, etc.)?". The TeX FAQ. 27 May 2018. Archived from the original on 28 April 2019. Retrieved 21 July 2019.
- ISBN 9780262691314
- ISBN 9780387952178
- ^ Knuth, Donald E (1996). "Questions and Answers II". TUGboat. 17: 355–367.
- ^ ISBN 978-1-57586-010-7.
- ^ Knuth, Donald E. Typesetting Concrete Mathematics, TUGboat 10 (1989), pp. 31–36, 342. Reprinted as chapter 18 of Digital Typography, pp. 367–378.
- ^ Vieth, Ulrik. "Math typesetting in TEX: The good, the bad, the ugly" (PDF). Archived from the original (PDF) on 20 January 2022.
- ^ "High-Quality Editing and Display of Mathematical Text in Office 2007".
- ^ "LineServices".
- ^ "Map" (PDF). ntg.nl.
- ^ Barnett, Michael P (1965), Computer Typesetting: Experiments and Prospects, Cambridge, MA: MIT Press
- ^ url=http://svn.tug.org/interviews/plass.html
- ^ Knuth & Plass 1981.
- ^ "Donald E. Knuth", TUGboat (interview), 21, Advogato: 103–10, 2000, archived from the original on 22 January 2009, retrieved 26 December 2005
- ^ "4.1 fmt: Reformat paragraph text", Core GNU utilities (GNU coreutils) manual, GNU Project, 2016
- ^ Liang 1983, p. 3.
- ^ Liang 1983.
- ^ "Appendix H: Hyphenation", The TeXbook, pp. 449–55
- ^ Knuth 1984, p. 127, Ch. 16: Typing Math Formulas.
- ^ Beebe 2004, p. 10.
- ^ a b Knuth, Donald E; MacKay, Pierre (1987), "Mixing Right-to-Left Texts with Left-to-Right Texts" (PDF), TUGboat, 8: 14–25.
- ^ Knuth, Donald E (1996), "Questions and Answers I", TUGboat, 17: 7–22.
- ^ Knuth, Donald E (1996), "Questions and Answers II", TUGboat, 17: 355–367.
- ^ "Helpful LaTeX Packages for Chemistry | Computational Chemistry Resources".
- arXiv:physics/0007040.
- ^ Knuth, Donald E. List of updates to the TeX82 listing published in September 1982, available on CTAN.
- ^ Knuth, Donald E. Appendix to the Errors of TeX paper, available on CTAN, last modified in January 2003.
- ^ Knuth, Donald E. "Knuth: Frequently Asked Questions". Stanford Computer Science. Archived from the original on 6 March 2008. Retrieved 28 November 2019.
- Stanford Magazine. Archived from the originalon 4 June 2006.
- ^ "History of TeX". TeX Users Group. Retrieved 28 November 2019.
- ^ Knuth, Donald E (2008). "Knuth: Recent News – Financial Fiasco". Stanford Computer Science. Archived from the original on 29 November 2019. Retrieved 29 November 2019.
- ^ Knuth, Donald E. (1986). "Remarks to Celebrate the Publication of Computers & Typesetting" (PDF). TUGboat. 7 (2): 95–98. Retrieved 6 December 2024.
- ^ Knuth, Donald E. (1990). "The Future of TeX and METAFONT" (PDF). TUGboat. 11 (4): 489. Retrieved 6 December 2024.
- ^ Knuth, Donald Ervin (1 November 1997). "Digital Typography: 1996 Kyoto Prize Lecture" (PDF). Kyoto Prize. The Inamori Foundation. Retrieved 6 December 2024.
- ^ "Trip", CTAN (source code), archived from the original (TeX) on 12 June 2021
- ISBN 0-201-13437-3
- ^ Open Source: Technology and Policy by Fadi P. Deek, James A. M. McHugh "Public domain", page 227 (2008)
- ^ "TeX Engine development". The TeX FAQ. 24 May 2018. Archived from the original on 28 April 2019. Retrieved 21 July 2019.
- ^ "The Communications of the TeX Users Group". tug.org. TeX Users Group. Retrieved 15 March 2019.
- ^ "All TeX User Groups". tug.org. TeX Users Group. Retrieved 17 November 2019.
- ^ Vim-LaTex, SourceForge, archived from the original on 8 March 2024
- ^ Automatic TeX plugin, Launch pad [permanent dead link]
- ^ TeX-9, Vim.org
- ^ TexMaths Homepage, free.fr
- ^ iMath, SourceForge
References
- Beebe, Nelson HF (2004), "25 Years of TeX and METAFONT: Looking Back and Looking Forward" (PDF), TUGboat, 25: 7–30.
- Knuth, Donald Ervin (1984), The TeXbook, ISBN 0-201-13448-9. The source code of the book in TeX (and a needed set of macros [1]) is available online on CTAN. It is provided only as an example and its use to prepare a book like The TeXbook is not allowed.
- ——— (1986), TeX: The Program, Computers and Typesetting, vol. B, Reading, ISBN 0-201-13437-3. The full source code of TeX; also available on CTAN. Being written using literate programming, it contains plenty of human-readable documentation.
- ——— (1999), Digital Typography, Lecture notes, Center for the Study of Language and Information, ISBN 1-57586-010-4.
- ———; Plass, Michael F (1981). "Breaking Paragraphs into Lines". Software: Practice and Experience. 11 (11): 1119–84. S2CID 206508107..
- ———, TeX (source code), archived from the original (WEB) on 27 September 2011 contains extensive documentation about the algorithms used in TeX.
- ISBN 0-201-52983-1.
- Liang, Franklin Mark (August 1983), Word Hy-phen-a-tion by Com-put-er (PhD thesis), Department of Computer Science, Stanford University.
- Salomon, David (1995), The Advanced TeXbook, Springer, ISBN 0-387-94556-3.
- Spivak, MD (1990), The Joy of TeX (reference) (2nd ed.), American Mathematical Society, ISBN 0-8218-2997-1on AMS-TeX.
- Vulis, Michael (1992), Modern TeX and Its Applications, CRC Press, ISBN 0-8493-4431-X.
External links
- TeX Users' Group
- TeX (questions and answers), StackExchange.
- Eijkhout, Victor. TeX by Topic Archived 25 February 2021 at the Wayback Machine
- TeX for the Impatient
- Donald Knuth discusses developing the software for TEX at Xerox PARC 2/21/1980 https://archive.org/details/xerox-parc-tapes-v49