# LaTeX

LaTeX (/ˈlɑːtɛk/ LAH-tek or /ˈleɪtɛk/ LAY-tek, often stylized as LaTeX) is a software system for typesetting documents. LaTeX markup describes the content and layout of the document, as opposed to the formatted text found in WYSIWYG word processors like Google Docs, LibreOffice Writer, and Microsoft Word. The writer uses markup tagging conventions to define the general structure of a document, to stylize text throughout a document (such as bold and italics), and to add citations and cross-references. A TeX distribution such as TeX Live or MiKTeX is used to produce an output file (such as PDF or DVI) suitable for printing or digital distribution.
LaTeX is widely used in academia for the communication and publication of scientific documents and technical note-taking in many fields, owing partially to its support for complex mathematical notation. It also has a prominent role in the preparation and publication of books and articles that contain complex multilingual materials, such as Arabic and Greek. LaTeX uses the TeX typesetting program for formatting its output, and is itself written in the TeX macro language.
LaTeX can be used as a standalone document preparation system, or as an intermediate format. In the latter role, for example, it is sometimes used as part of a pipeline for translating DocBook and other XML-based formats for PDF. The typesetting system offers programmable desktop publishing features and extensive facilities for automating most aspects of typesetting and desktop publishing, including numbering and cross-referencing of tables and figures, chapter and section headings, graphics, page layout, indexing and bibliographies.
Like TeX, LaTeX started as a writing tool for mathematicians and computer scientists, but even from early in its development, it has also been taken up by scholars who needed to write documents that include complex math expressions or non-Latin scripts, such as Arabic, Devanagari, and Chinese.
LaTeX is intended to provide a high-level, descriptive markup language to utilize TeX more easily. TeX handles the document layout, while LaTeX handles the content side for document processing. LaTeX comprises a collection of TeX macros and a program to process LaTeX documents, and because the plain TeX formatting commands are elementary, it provides authors with ready-made commands for formatting and layout requirements such as chapter headings, footnotes, cross-references and bibliographies.
LaTeX was originally written in the early 1980s by Leslie Lamport at SRI International. The current version is LaTeX2e, first released in 1994 but incrementally updated starting in 2015. This update policy replaced earlier plans for a separate release of LaTeX3, which had been in development since 1989. LaTeX is free software and is distributed under the LaTeX Project Public License (LPPL).

## History

LaTeX was created in the early 1980s by Leslie Lamport when he was working at Stanford Research Institute (SRI). He needed to write TeX macros for his own use and thought that with a little extra effort, he could make a general package usable by others. Peter Gordon, an editor at Addison-Wesley, convinced him to write a LaTeX user's manual for publication (Lamport was initially skeptical that anyone would pay money for it); it came out in 1986 and sold hundreds of thousands of copies. Meanwhile, Lamport released versions of his LaTeX macros in 1984 and 1985. On 21 August 1989, at a TeX Users Group (TUG) meeting at Stanford, Lamport agreed to turn over maintenance and development of LaTeX to Frank Mittelbach. Mittelbach, along with Chris Rowley and Rainer Schöpf, formed the LaTeX3 team; in 1994, they released LaTeX2e, the current standard version. LaTeX3 has since been cancelled with features intended for that version being back-ported to LaTeX2e since 2018.

## Typesetting system

LaTeX attempts to follow the design philosophy of separating presentation from content, so that authors can focus on the content of what they are writing without attending simultaneously to its visual appearance. In preparing a LaTeX document, the author specifies the logical structure using simple, familiar concepts such as chapter, section, table, figure, etc., and lets the LaTeX system handle the formatting and layout of these structures. As a result, it encourages the separation of the layout from the content — while still allowing manual typesetting adjustments whenever needed. This concept is similar to the mechanism by which many word processors allow styles to be defined globally for an entire document, or the use of Cascading Style Sheets in styling HyperText Markup Language (HTML) documents.
The LaTeX system is a markup language that handles typesetting and rendering, and can be arbitrarily extended by using the underlying macro language to develop custom macros such as new environments and commands. Such macros are often collected into packages, which could then be made available to address some specific typesetting needs such as the formatting of complex mathematical expressions or graphics (e.g., the use of the align environment provided by the amsmath package to produce aligned equations).
To create a document in LaTeX, a user first creates a file, such as document.tex, typically using a text editor. The user then gives their document.tex file as input to the TeX program (with the LaTeX macros loaded), which prompts TeX to write out a file suitable for onscreen viewing or printing. This write-format-preview cycle is one of the chief ways in which working with LaTeX differs from the What-You-See-Is-What-You-Get (WYSIWYG) style of document editing. It is similar to the code-compile-execute cycle known to computer programmers. Today, many LaTeX-aware editing programs make this cycle a simple matter through the pressing of a single key, while showing the output preview on the screen beside the input window. Some online LaTeX editors even automatically refresh the preview, while other online tools provide incremental editing in-place, mixed in with the preview in a single window.

## Example

The example below shows the input to LaTeX and the corresponding output from the system:
| Input | Output |
| \documentclass{article} % Starts an article \usepackage{amsmath} % Imports amsmath \title{\LaTeX} % Title \begin{document} % Begins a document \maketitle \LaTeX is a document preparation system for the \TeX typesetting program. It offers programmable desktop publishing features and extensive facilities for automating most aspects of typesetting and desktop publishing, including numbering and cross-referencing, tables and figures, page layout, bibliographies, and much more. \LaTeX was originally written in 1984 by Leslie Lamport and has become the dominant method for using \TeX; few people write in plain \TeX anymore. The current version is \LaTeXe. % This is a comment, not shown in final output. % The following shows typesetting power of LaTeX: \begin{align} E_0 &= mc^2 \\ E &= \frac{mc^2}{\sqrt{1-\frac{v^2}{c^2}}} \end{align} \end{document} | |

## Pronouncing and writing "LaTeX"

The characters 'T', 'E', and 'X' in the name come from the Greek capital letters tau, epsilon, and chi, as the name of TeX derives from the Ancient Greek: τέχνη ('skill', 'art', 'technique'); for this reason, TeX's creator Donald Knuth promotes its pronunciation as /tɛx/ (tekh) (that is, with a voiceless velar fricative as in Modern Greek, similar to the ch in loch). Lamport remarks that "TeX is usually pronounced tech, making lah-tech, lah-tech, and lay-tech the logical choices; but language is not always logical, so lay-tecks is also possible."
The name is printed in running text with a typographical logo: LaTeX. In media where the logo cannot be precisely reproduced in running text, the word is typically given the unique capitalization LaTeX. Alternatively, the TeX, LaTeX, and XeTeX logos can also be rendered via pure CSS and XHTML for use in graphical web browsers — by following the specifications of the internal \LaTeX macro.

## Related software

As a macro package, LaTeX provides a set of macros for TeX to interpret. There are many other macro packages for TeX, including Plain TeX, GNU Texinfo, AMSTeX, and ConTeXt.
When TeX "compiles" a document, it follows (from the user's point of view) the following processing sequence: Macros → TeX → Driver → Output. Different implementations of each of these steps are typically available in TeX distributions. Traditional TeX will output a DVI file, which is usually converted to a PostScript file. In 2000, Hàn Thế Thành and others wrote an implementation of TeX called pdfTeX, which also outputs to PDF and takes advantage of features available in that format. The XeTeX engine developed by Jonathan Kew, on the other hand, merges modern font technologies and Unicode with TeX. LuaTeX is an extended version of pdfTeX using Lua as an embedded scripting language.
There are also many editors for LaTeX, some of which are offline, source-code-based while others are online, partial-WYSIWYG-based. For more, see Comparison of TeX editors.

## Compatibility and converters

LaTeX documents (*.tex) can be opened with any text editor. They consist of plain text and contain no hidden formatting codes or binary information. TeX documents can also be shared by rendering the LaTeX file to other formats such as OpenDocument, XML, or class (*.cls) files. LaTeX can also (and commonly is) rendered to PDF files using the LaTeX extension pdfLaTeX. LaTeX files containing Unicode text can be processed into PDFs with the inputenc package, or by the TeX extensions XeLaTeX and LuaLaTeX.
* TeX4ht is a converter that can translate TeX and LaTeX documents to HTML and certain XML formats. It is now included preconfigured with all TeX distributions.
* HeVeA is a converter written in OCaml that converts LaTeX documents to HTML5. This way documents such as scientific papers, primarily typeset for printing, can be placed on the World Wide Web for online viewing. It is licensed under the Q Public License.
* LaTeX2HTML is a converter written in Perl that converts LaTeX documents to HTML. It is licensed under GPL v2. The latest updates are available from Comprehensive TeX Archive Network (CTAN).
* LaTeX2RTF is a converter written in C that converts LaTeX documents to RTF. It is licensed under GPL v2 or later.
* LaTeXML is a converter written in Perl that converts LaTeX documents into a variety of XML-based formats, including HTML5 (with MathML), ePub ebooks, JATS, and TEI. It was developed at the National Institute of Standards and Technology by US Federal Government employees and is therefore in the public domain. It is available for free.
* Pandoc is a "universal document converter" able to transform LaTeX (as well as other formats) into many different file formats, including HTML5, ePub, OpenDocument (*.odt), Microsoft Office Open XML (*.docx), and even text with MediaWiki markup as used in Wikipedia. It is licensed under GPL v2.
LaTeX has become the de facto standard to typeset mathematical expression in scientific documents. Hence, there are several conversion tools focusing on mathematical LaTeX expressions, such as converters to MathML or Computer Algebra System.
* MathJax is a JavaScript library for converting LaTeX to MathML, picture formats including SVG and PNG, or HTML for embedding within a webpage.
** The Wikimedia Foundation uses MathJax to build Mathoid, a web service that uses Node.js to render math that is used in Wikipedia.
* KaTeX is a JavaScript library for converting LaTeX to HTML and MathML. It is developed by Khan Academy, and is among the fastest LaTeX to HTML converters.

## Licensing

LaTeX is typically distributed along with plain TeX under a free software licence: the LaTeX Project Public License (LPPL). The LPPL is not compatible with the GNU General Public License, as it requires that modified files must be clearly differentiable from their originals (usually by changing the filename); this was done to ensure that files that depend on other files will produce the expected behavior and avoid dependency hell. The LPPL is Debian Free Software Guidelines (DFSG) compliant as of version 1.3. As free software, LaTeX is available on most operating systems, which include Unix (Solaris, HP-UX, AIX), BSD (FreeBSD, macOS, NetBSD, OpenBSD), Linux (Red Hat, Debian, Arch, Gentoo), Windows, DOS, RISC OS, AmigaOS, and Plan 9.

## Versions

LaTeX2e is the current version of LaTeX, since it replaced LaTeX 2.09 in 1994. As of 2020, LaTeX3, which started in the early 1990s, is under a long-term development project. Planned features include improved syntax (separation of content from styling), hyperlink support, a new user interface, access to arbitrary fonts and a new documentation. Some LaTeX3 features are available in LaTeX2e using packages, and by 2020 many features have been enabled in LaTeX2e by default for a gradual transition.
There are many commercial implementations of the entire TeX system. System vendors may add extra features like added typefaces and telephone support. LyX is a free software, WYSIWYM visual document processor that uses LaTeX for a back-end. TeXmacs is a free, WYSIWYG editor with similar functionalities as LaTeX, but with a different typesetting engine. Other WYSIWYG editors that produce LaTeX include Scientific Word on Windows and macOS.
Many community-supported TeX distributions are available.