LaTeX
LaTeX is a document preparation system and macro package for the TeX typesetting engine, designed to produce high-quality technical and scientific documents, especially those featuring complex mathematical notation.[1] It allows users to write documents using a markup language that separates content from presentation, enabling automated formatting for elements like equations, tables, figures, bibliographies, and cross-references.[2] Developed by Leslie Lamport in the late 1970s and early 1980s as an extension of Donald Knuth's TeX program—which Knuth created starting in 1978 to address limitations in traditional typesetting for his multivolume The Art of Computer Programming—LaTeX simplifies TeX's low-level commands into higher-level structures for easier use by non-experts.[3][4] The system's core philosophy emphasizes portability, consistency, and precision, producing output in formats such as PDF or DVI that is suitable for professional printing and digital distribution.[1] LaTeX supports a wide range of document classes, including article, book, and report, and is highly extensible through thousands of packages available from the Comprehensive TeX Archive Network (CTAN), covering topics from graphics and fonts to multilingual typesetting.[2] Since its first widely available version (LaTeX 2.09) in the mid-1980s and the stable LaTeX2ε release in 1994, it has been maintained by the volunteer LaTeX Project team, with ongoing updates for modern features like UTF-8 encoding support introduced in 2018.[5][2] Widely adopted in academia, research, and publishing due to its reliability and ability to handle intricate layouts without proprietary software, LaTeX runs on all major platforms via free distributions like TeX Live and has been used by millions for theses, journal articles, and books.[1] Its open-source nature under the LaTeX Project Public License ensures community-driven evolution, making it a standard tool for precise document creation in fields requiring rigorous notation and structure.[6]History and Development
Origins and Creation
Donald Knuth initiated the development of TeX in 1978, motivated by frustration with the inadequate quality of digital typesetting encountered in computer science publications. Specifically, while preparing galley proofs for the second volume of his seminal work The Art of Computer Programming, Knuth was dismayed by the poor typographic results produced by the publisher's new computerized system, prompting him to design a precise tool for high-quality mathematical and technical typesetting.[7][8] In the early 1980s, Leslie Lamport, a computer scientist at SRI International, built upon Knuth's TeX by creating LaTeX as a set of macros to simplify its use for document authors without deep typesetting expertise. Lamport aimed to abstract TeX's low-level programming into higher-level commands, enabling users to focus on content rather than formatting details. LaTeX's first public release occurred in 1984, marking it as an accessible extension of TeX's underlying macro language.[9] The primary goals of LaTeX were to establish a markup-based system for producing structured documents, emphasizing separation of content from presentation to facilitate collaborative technical writing, especially in fields requiring complex mathematics. By treating documents as marked-up text files, LaTeX allowed authors to describe logical structure—such as sections, equations, and references—while automatically handling layout and typography for professional output. This approach was particularly suited to scientific and academic authoring, where precision in rendering formulas and symbols is essential.[9] LaTeX gained early traction within academic communities in mathematics and physics, where its capabilities for typesetting intricate equations and structured papers aligned with the needs of researchers sharing preprints and manuscripts. The American Mathematical Society became a prominent early promoter, integrating LaTeX enhancements into its publication workflows and fostering its spread through user meetings and style guides.Key Milestones
In 1985, LaTeX achieved its first widespread distribution through DECUS tapes, enabling broader adoption among users of Digital Equipment Corporation systems and marking a key step in its dissemination beyond initial academic circles.[10] The LaTeX Project Team was formed in 1989, with Leslie Lamport handing over development responsibilities to Frank Mittelbach, Chris Rowley, and Rainer Schöpf, establishing a collaborative framework for ongoing maintenance and enhancements.[11] The LaTeX3 project, aimed at redesigning the system for greater extensibility and robustness, was initiated in 1990, laying the groundwork for future programming interfaces.[12] During the early 1990s, the team introduced the New Font Selection Scheme (NFSS) in 1993, which revolutionized font handling by providing a more flexible and scalable model for selecting and encoding typefaces, addressing limitations in earlier versions.[13] This was followed by the release of LaTeX2e in 1994, which unified disparate variants of LaTeX into a single, extensible kernel, standardizing features like document classes and packages while ensuring backward compatibility.[14] Spanning the 2010s and 2020s, the LaTeX3 project made significant progress, particularly through the development of the expl3 syntax, a robust programming layer introduced in its modern form around 1998 and refined over decades to enable systematic, error-resistant code with features like expandable functions and comprehensive testing suites.[15] By 2025, major distributions such as TeX Live integrated enhanced Unicode support, leveraging LuaTeX's native capabilities for better handling of international characters and scripts, with LuaTeX increasingly positioned as the default engine for modern workflows due to its scripting integration and output versatility.[16]Evolution of Standards
The LaTeX Project Team, formed in the late 1980s to oversee the evolution of LaTeX from its initial 1985 release, has played a pivotal role in maintaining and refining the system's standards, ensuring compatibility, stability, and enhancements across distributions.[9] This team, comprising core developers like Frank Mittelbach and David Carlisle, coordinates releases, resolves inconsistencies in the kernel, and integrates community feedback to uphold high-quality typesetting practices.[17] Their efforts include regular updates to the LaTeX format, such as the biannual releases that incorporate bug fixes and new features while preserving backward compatibility.[18] A key aspect of these standardization initiatives is the development of authoritative style guides, notably the LaTeX Companion series, which has profoundly influenced best practices among users and developers since its first edition in 1993.[19] Authored by LaTeX Project Team members including Frank Mittelbach and Michel Goossens, the series provides detailed documentation on core commands, package integration, and document structuring, serving as a de facto reference for consistent usage.[20] The third edition, released in 2023 as a two-volume set, expands coverage to modern workflows, emphasizing modular design and accessibility, thereby guiding the community toward standardized, reproducible document production.[21] Central to LaTeX's standardization is the LaTeX2e format, introduced in 1994, which formalized core document classes such as article, report, and book, along with essential environments to ensure uniform structure and output across implementations.[22] The article class, designed for shorter publications, defaults to one-sided layout with optional abstracts and supports environments like enumerate, itemize, and figure for lists and floating elements.[22] In contrast, the book class accommodates two-sided printing with openright chapters and dedicated title pages, while environments such as thebibliography and theindex provide standardized formatting for references and indices, all governed by configurable options like paper size and font scaling (10pt, 11pt, 12pt).[22] These elements, defined in the kernel, promote interoperability and have remained foundational since LaTeX2e's adoption as the stable standard.[23] In the 2020s, efforts to align LaTeX with contemporary archival standards have advanced through integrations with modern engines like XeLaTeX, enabling PDF/A compliance for long-term document preservation.[24] Packages such as pdfx, updated in recent years, facilitate PDF/A-1b and PDF/A-2b generation when compiled with XeLaTeX, embedding metadata, fonts, and ICC profiles to meet ISO 19005 requirements without altering core LaTeX syntax.[25] Similarly, ConTeXt's LuaTeX-based architecture has influenced hybrid approaches, allowing LaTeX users to leverage its advanced output routines for standards-compliant PDFs in specialized workflows.[26] The LaTeX3 programming layer, integrated progressively since 2020, further supports these developments by enhancing font handling and hook systems for robust compliance.[27] Community-driven standards have also been bolstered by the Comprehensive TeX Archive Network (CTAN), established in 1992 to centralize package distribution and enforce consistent archiving protocols.[28] Initiated by developers including Rainer Schöpf and Sebastian Rahtz, CTAN synchronizes mirrors worldwide, categorizing contributions into directories like macros/latex/contrib to prevent fragmentation and ensure verifiable, versioned access to extensions.[28] This infrastructure, modeled after similar systems like CPAN, has standardized package metadata and licensing, fostering a collaborative ecosystem that aligns with LaTeX's core principles of portability and openness.[28] The LaTeX3 project has contributed to these standards by providing an experimental programming foundation that informs kernel updates, though its full integration remains ongoing.[27]Technical Overview
Core Typesetting System
LaTeX functions as a high-level macro package layered atop the TeX typesetting engine, where TeX manages the low-level details of character placement, line justification, and page layout, while LaTeX supplies a declarative markup language for structuring documents such as articles, books, and reports.[29][30] This architecture allows LaTeX to abstract TeX's primitives into user-friendly commands, enabling focus on content rather than precise formatting rules.[30] The processing pipeline begins with a LaTeX source file, typically ending in.tex, which is compiled by a TeX engine such as pdfTeX for direct PDF output or XeTeX for Unicode and font support.[31] The engine reads the file token by token, expanding macros and invoking primitives to build a device-independent (DVI) file or PDF, with multiple passes often required to resolve references and counters.[30]
LaTeX commands are macros defined using TeX's \def or \newcommand, which expand sequentially during processing into sequences of TeX primitives for rendering.[29][30] This expansion replaces the command with its parameter text, substituting arguments and potentially triggering further expansions until only primitives remain, such as \hbox for horizontal boxes or \glue specifications for spacing.[30][32]
TeX operates in distinct modes to handle layout: vertical mode stacks material top-to-bottom, as in page construction, while horizontal mode assembles items side-by-side within lines or boxes.[33] Fundamental to this are boxes, which encapsulate content as indivisible units (e.g., \hbox for horizontal, \vbox for vertical), and glue, stretchable or shrinkable spaces that adjust to fit constraints like line width.[30][33]
Recent updates to LaTeX2e, including the 2025-06-01 release, introduced configurable output routines with hooks and sockets for safer customization of page building, along with a new flexible mark mechanism using commands like \InsertMark, \FirstMark, and \LastMark to replace the legacy system.[34]
For paragraph shaping, TeX employs the Knuth-Plass algorithm, a dynamic programming approach that minimizes overall "badness" across lines by evaluating feasible breaks at glue points and penalties.[35][36] The line width is governed by the \hsize parameter, and badness for a line is computed as
\text{badness} = 100 \times \left( \frac{|d|}{\hsize} \right)^3
where d is the deviation (stretch or shrink) needed to fit the line, with penalties added for undesirable breaks like those after the first or before the last line of a paragraph.[35][36] This global optimization ensures justified text with even spacing and controlled hyphenation.[35]
Syntax and Commands
LaTeX employs a command-based markup language where instructions for typesetting are given through macros prefixed by a backslash character,\. The standard syntax for a command is \command[optional]{mandatory}, in which the optional argument, if present, is delimited by square brackets [] and precedes the mandatory argument enclosed in curly braces {}. This structure allows flexibility in specifying parameters, with the command name itself consisting of either a sequence of letters (e.g., \section) or a single non-letter character (e.g., \#). Commands are case-sensitive, and some include a starred variant (e.g., \section*) that modifies their behavior, such as suppressing numbering.[37]
Commands in LaTeX are broadly categorized into structural, formatting, and mathematical types, each serving distinct roles in document preparation. Structural commands establish the overall framework of the document; for instance, \documentclass{article} specifies the document class at the preamble, selecting predefined formatting options like page layout and font styles, while \begin{document} initiates the body of the text where content is rendered, and \end{document} concludes it. These ensure a consistent typesetting environment from the outset. Formatting commands modify the appearance of text elements, such as \textbf{text} to produce boldface output or \textit{text} to apply italics, applying changes locally within their argument scopes without altering the global structure. Mathematical commands operate within dedicated math modes and include symbols like \alpha for the Greek letter α, enabling precise rendering of equations and expressions.[29][38]
In the 2025-11-01 release, new commands were added such as \DeclareMathScriptfontMapping for handling separate script fonts in math mode and \NewStructureName for symbolic structure names in tagged PDF support.[39]
Mathematical content in LaTeX is handled through two primary modes: inline math, delimited by single dollar signs $...$, which integrates formulas seamlessly into text lines (e.g., $E = mc^2$), and display math, using double dollar signs $$...$$ or the preferred $$...$$ delimiters for centered, standalone equations with enhanced spacing. The $$...$$ form is recommended over $$...$$ as it integrates better with LaTeX's error-checking mechanisms and supports package extensions. Transitioning into math mode activates specialized typesetting rules, such as automatic spacing around operators and italicization of variables.[40]
Recent enhancements in the 2025 releases include improved math tagging in tabular cells and support for MathML attributes via \MathMLintent and \MathMLarg, aiding accessibility in PDF output.[34][39]
Environments provide a mechanism to encapsulate blocks of content with specific formatting rules, invoked via the paired commands \begin{environment} ... \end{environment}. The environment name must match exactly between the begin and end declarations; mismatches trigger compilation errors. Common environments include those for lists (e.g., \begin{itemize} \item First point \item Second point \end{itemize} for bulleted lists), tables (e.g., \begin{tabular}{cc} a & b \\ c & d \end{tabular} for aligned columns), and figures (e.g., \begin{figure} \caption{Description} \end{figure} to position and label images). These create grouped scopes where additional commands can apply localized effects, such as alignment or numbering.[41]
Among the essential commands for organizing content, \section{Title} generates a numbered section heading and updates the table of contents if applicable, facilitating hierarchical document structure. Cross-referencing is achieved using \label{key} placed after a numbered element like a section or equation, which stores a unique identifier, and \ref{key} to retrieve the corresponding number in the output (e.g., "See Section \ref{sec:example}"). Multiple passes of the LaTeX processor may be required to resolve references accurately, as labels are defined forward or backward in the source. The \pageref{key} variant provides the page number instead.[42]
Syntax errors in LaTeX often arise from structural mismatches, with unmatched braces being particularly prevalent; every opening { must pair with a closing }, as unbalanced delimiters disrupt argument parsing and lead to "Runaway argument?" or "Missing } inserted" messages during compilation. Resolution involves inspecting the error log for the line number indicated, then systematically checking nested braces—tools like syntax highlighters or editors with brace matching (e.g., in TeXShop or Overleaf) aid in locating the discrepancy. Other frequent issues include omitted backslashes before command names or mismatched environment tags, which can be rectified by verifying the source code sequentially from the error point. Proper indentation and commenting can prevent such errors in complex documents.[43][44]
Document Processing Model
The process of creating a LaTeX document begins with editing a source file with the extension.tex using a plain text editor, where users input markup commands to define the document's structure and content.[29] This source file serves as the primary input for the typesetting engine.
Compilation is initiated by invoking a LaTeX engine such as latex or pdflatex from the command line or an integrated development environment, which processes the .tex file to generate an output document.[29] During this step, the engine produces auxiliary files, including the .aux file that records information for cross-references, citations, and table of contents (TOC) entries, and the .log file that logs the compilation process, warnings, and errors for debugging.[45] These files are essential for resolving dependencies in complex documents.
LaTeX compilation often requires multiple passes over the source file to fully resolve elements like references and TOCs, as initial runs generate incomplete auxiliary data that subsequent passes use to finalize page numbers and hyperlinks.[29] For instance, after the first pass creates the .aux file, a second pass incorporates the resolved references before producing the final output.
Bibliography processing integrates into this workflow via tools like BibTeX or the biblatex package; users maintain a separate .bib database of references, run the LaTeX compiler to generate a .aux file with citation queries, then execute BibTeX to produce a .bbl file containing formatted entries, followed by additional LaTeX passes to insert the bibliography.[46]
Index and glossary generation follows a similar multi-step procedure using the makeindex utility; after an initial LaTeX run marks index entries in the .aux file, makeindex processes these to create an .ind file, which is then incorporated in a final compilation pass.[47]
Traditional LaTeX engines output Device Independent (DVI) files, which can be converted to PDF using tools like dvipdfm or dvipdfmx, whereas pdflatex directly generates PDF output, supporting modern features like embedded fonts and hyperlinks from the outset.[48]
As of late 2024, LuaLaTeX has been recommended as the primary engine for LaTeX, extending pdfTeX with an embedded Lua scripting language for dynamic control over typesetting, including advanced font handling with OpenType and TrueType formats, and seamless integration of Lua code for custom automation within the compilation process.[49]
The 2025 LaTeX2e releases (June and November) have enhanced PDF output through the Tagged PDF project, enabling better accessibility features such as structure tagging for screen readers, MathML integration for equations, and metadata options via \DocumentMetadata. These updates include default PDF 2.0 support, expanded tagging for graphics (e.g., alt text), and improved paragraph and math tagging mechanisms. Additionally, several legacy packages like enumerate and theorem have been retired in favor of modern alternatives.[34][39][50]
Usage and Examples
Basic Document Structure
A LaTeX document follows a standardized structure divided into a preamble, where setup instructions are provided, and a body, where the actual content resides. This separation ensures that formatting and typesetting rules are defined upfront, allowing the processor to generate a consistent output, such as a PDF. The entire document must be enclosed within the\begin{document} and \end{document} commands to initiate and terminate processing.[29]
The preamble precedes the document environment and contains essential declarations. It starts with the \documentclass[options]{class} command, which selects a predefined template for the document type—such as article for short papers, report for longer documents, or book for multi-chapter works—and applies any specified options. Standard options include font sizes of 10pt, 11pt, or 12pt to set the base text size (with 10pt as the default if unspecified), and paper dimensions like a4paper for A4 format or letterpaper for US letter size.[51] Following this, additional functionality is incorporated via \usepackage{packagename} commands, which load extension modules for features like graphics, mathematics, or bibliography management without altering the core structure.[52] Metadata such as the document's title, author, and date is also defined here using \title{title text}, \author{author name}, and \date{date} (with the date optional and defaulting to the compilation time).[29]
The document body begins after \begin{document} and holds all user content, including text, sections, figures, and tables structured through commands and environments. To generate a title page or header from the preamble metadata, the \maketitle command is placed early in the body. Front and back matter elements enhance navigation and references: \tableofcontents produces a table of contents based on section headings, \listoffigures lists included images with their captions, and \bibliography{bibfilename} (preceded by \bibliographystyle{style} in the preamble) compiles a bibliography from a .bib file.[29] These components assume standard classes and may require packages like tocloft for customization, though the basic forms suffice for most documents.[52]
For a minimal working template using the article class, the following skeleton provides the essential framework:
This example compiles a simple document with a title page, table of contents placeholder, and bibliography stub, assuming alatex\documentclass[12pt,a4paper]{article} \title{Document Title} \author{Author Name} \date{\today} \begin{document} \maketitle \tableofcontents \section{Section One} Content goes here. \bibliographystyle{plain} \bibliography{references} \end{document}\documentclass[12pt,a4paper]{article} \title{Document Title} \author{Author Name} \date{\today} \begin{document} \maketitle \tableofcontents \section{Section One} Content goes here. \bibliographystyle{plain} \bibliography{references} \end{document}
references.bib file exists.[29]
Simple Example
A simple LaTeX document demonstrates the essential elements of typesetting, including the preamble for setup, the document body for content, and basic structural commands for sections, mathematics, and figures. This example creates a short article titled "A Brief Introduction to Mathematics," featuring a section, an inline equation, a displayed equation using Euler's identity, and a placeholder for a figure.[9] To compile such a document, users typically install a TeX distribution, which provides the necessary engines and packages. Common options for beginners include TeX Live, a cross-platform distribution maintained by the TeX Users Group, or MiKTeX, a Windows-focused system with on-demand package installation; both are free and include the pdfLaTeX compiler for generating PDF output from .tex files.[53][54][55] The following is the complete source code for the example document, saved assimple_article.tex:
When compiled with pdfLaTeX, this produces a single-page PDF with a title page section displaying the article's title, author, and current date in large, centered formatting. The body follows with a level-1 heading "Key Concepts" in larger, bold font, followed by a paragraph of plain text. The inline equation renders the value of e in italicized mathematical notation. The displayed equation appears centered on its own line, typeset in display math mode with proper spacing for the exponential, imaginary unit, pi, and equality. The figure placeholder shows a black rectangle as a stand-in for an image, accompanied by an italicized caption below it; in a real document, this would be replaced bylatex\documentclass{article} \title{A Brief Introduction to Mathematics} \author{John Doe} \date{\today} \begin{document} \maketitle \section{Key Concepts} Mathematics often involves fundamental identities. For instance, the number $e$ approximates 2.71828 and is central to calculus. Euler's identity elegantly connects five constants: \begin{equation} e^{i\pi} + 1 = 0 \end{equation} \begin{figure}[h] \centering \rule{5cm}{3cm} % Placeholder for an image \caption{A diagram illustrating the unit circle in the complex plane.} \label{fig:complex} \end{figure} \end{document}\documentclass{article} \title{A Brief Introduction to Mathematics} \author{John Doe} \date{\today} \begin{document} \maketitle \section{Key Concepts} Mathematics often involves fundamental identities. For instance, the number $e$ approximates 2.71828 and is central to calculus. Euler's identity elegantly connects five constants: \begin{equation} e^{i\pi} + 1 = 0 \end{equation} \begin{figure}[h] \centering \rule{5cm}{3cm} % Placeholder for an image \caption{A diagram illustrating the unit circle in the complex plane.} \label{fig:complex} \end{figure} \end{document}
\includegraphics{filename} from the graphicx package, though here it uses core LaTeX for simplicity.[9]
Breaking down the code line by line reveals LaTeX's declarative structure, where commands begin with a backslash and the document is processed in a single pass to generate formatted output.[9]
-
\documentclass{[article](/page/Article)}: Specifies the article class, which sets default page margins, fonts (10pt Computer Modern), and layout for non-book documents; this is the minimal required declaration in the preamble. -
\title{...},\author{...},\date{...}: Define metadata for the title block; these are standard commands in the article class and do not appear until invoked.[9] -
\begin{document}and\end{document}: Enclose the body, switching from preamble (setup) to content; everything before\begin{document}configures the document class, while the body contains the visible text.[9] -
\maketitle: Generates the formatted title, author, and date block at the current position, using large centered text.[9] -
\section{Key Concepts}: Creates a numbered section heading, automatically incrementing the section counter and adding it to the table of contents if enabled; headings use a larger bold font with vertical spacing. - The paragraph text: Plain LaTeX input is automatically hyphenated and justified into lines, with ... delimiters activating inline math mode for the approximation of e.[9]
-
\begin{equation} ... \end{equation}: Defines a displayed, centered equation environment, numbering it automatically (e.g., (1)) and rendering symbols like e, i, \pi in professional math italics with proper kerning; this uses core LaTeX math without extensions. -
\begin{figure}[h] ... \end{figure}: Opens a floating figure environment with specifier requesting "here" placement if possible;\centeringaligns content,\rule{5cm}{3cm}draws a simple black rectangle as a placeholder,\caption{...}adds descriptive text below, and\label{fig:complex}enables cross-referencing (e.g., "see Figure~\ref{fig:complex}").
Advanced Formatting Techniques
LaTeX provides powerful mechanisms for defining custom commands, enabling users to create reusable macros that simplify complex formatting and promote consistency across documents. The \newcommand primitive allows the definition of new commands with optional arguments, such as \newcommand{\mycmd}[56]{#1 squared}, which can then be invoked as \mycmd{x} to produce "x squared". This feature enhances reusability by encapsulating repetitive structures, reducing errors in professional typesetting.[57] For mathematical content, LaTeX offers advanced environments like align* and equation* from the amsmath package, which facilitate aligned multiline equations without numbering in the starred variants. These environments support precise alignment on operators, such as equals signs, improving readability in derivations. Additionally, the amsthm package enables the declaration of theorem-like environments, such as \newtheorem{theorem}{Theorem}, for structuring proofs and statements in academic writing.[58][59] Tables in LaTeX are constructed using the tabular environment for text-based grids, where column specifications like {lcr} define left, center, or right alignment, as in \begin{tabular}{lcr} a & b & c \ \end{tabular}. For mathematical tables, the array environment operates similarly but within math mode, allowing seamless integration of formulas in cells, such as matrices. Figures are incorporated via the \includegraphics command, which supports scaling and positioning options like \includegraphics[width=0.5\textwidth]{image.png}, enabling professional inclusion of graphics while maintaining document flow.[60][61] Typography in LaTeX can be finely tuned through length parameters, for instance, \setlength{\parindent}{0pt} to suppress indentation at paragraph starts, fostering a modern layout style. Hyphenation patterns, controlled by commands like \hyphenation{man-u-script}, allow explicit breaks for specific words, overriding default language rules to prevent awkward line divisions in justified text. These adjustments ensure optimal spacing and readability in complex documents.[22][62] A representative complex equation, such as solving the quadratic formula, demonstrates multiline derivation capabilities:This uses the align* environment to align steps horizontally, showcasing LaTeX's strength in precise mathematical typesetting.[58]latex\begin{align*} ax^2 + bx + c &= 0 \\ x &= \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} \end{align*}\begin{align*} ax^2 + bx + c &= 0 \\ x &= \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} \end{align*}
Ecosystem and Extensions
Packages and Macros
LaTeX significantly extends its core typesetting capabilities through a rich ecosystem of user-contributed packages, primarily distributed via the Comprehensive TeX Archive Network (CTAN). As of November 2025, CTAN hosts 6828 packages, the majority of which are free and compatible with LaTeX, enabling enhancements for graphics, hyperlinks, multilingual support, and more specialized formatting needs.[63] These packages are incorporated into documents using the \usepackage command in the preamble, which loads the specified package and makes its macros available throughout the document. For example, \usepackage{graphicx} provides commands like \includegraphics for embedding images from various formats, while \usepackage{hyperref} adds support for interactive elements such as clickable links and bookmarks in PDF outputs.[2] In addition to packages, LaTeX supports macro programming to define custom commands, allowing users to encapsulate complex formatting or repetitive structures into reusable definitions. The TeX primitive \def enables basic macro creation by associating a control sequence with a token sequence, though it risks overwriting existing commands without warning. In contrast, LaTeX's \newcommand offers safer definition by erroring if the command already exists, promoting robust code; for redefinitions, \renewcommand is used. Parameter handling is integral, with mandatory arguments passed in braces and optional ones in brackets, as in \newcommand{\person}[64][Mr.]{\text{#1.~#2}} to default a title if unspecified.[2] Among the most widely adopted packages are those addressing common document requirements in academic and technical writing. The amsmath package, a cornerstone of the AMS-LaTeX bundle, extends LaTeX's mathematical facilities with environments for aligned equations, gathered multiline displays, and improved spacing, essential for rigorous scientific typesetting.[65] Biblatex reimplements LaTeX's bibliography tools, providing flexible citation styles, Unicode compatibility, and integration with the Biber processor for handling complex metadata and sorting schemes.[66] For visualizations, the TikZ frontend to the PGF system allows declarative creation of diagrams, graphs, and illustrations, supporting layers, paths, and nodes for precise, vector-based output without external tools.[67] LaTeX3 advances macro programming via the expl3 module, a dedicated layer for functional-style coding that abstracts TeX primitives into consistent, expandable functions. This module facilitates handling of variables like token lists (tl), sequences (seq), and property lists (prop), enabling modular package development across engines like pdfTeX, XeTeX, and LuaTeX. A representative example is \tl_set:Nn \l_my_tl { content }, which assigns the balanced token list { content } to the local variable \l_my_tl for subsequent manipulation, such as concatenation or conditional processing.[68] Effective use of packages and macros requires adherence to best practices to maintain document stability. To avoid conflicts, packages should be loaded in a deliberate order—such as placing hyperref near the end of the preamble—and LaTeX's hook system can be leveraged to defer code execution regardless of loading sequence. Custom macros benefit from prefixed names (e.g., \mypkg_macro:) to namespace internals and prevent clashes with other contributions. Updates are managed via tlmgr in TeX Live distributions, using tlmgr update --all to synchronize packages from CTAN while options like --backupdir enable versioning to revert incompatible changes.[69][70][71]Related Software Tools
Overleaf is a cloud-based LaTeX editor that supports real-time collaboration among multiple users, eliminating the need for local installations and enabling seamless version control through integrated history tracking.[72] TeXstudio provides a graphical user interface (GUI) for LaTeX editing, featuring auto-completion for commands, syntax highlighting, and an integrated PDF viewer to facilitate efficient document compilation and preview.[73] Similarly, the LaTeX Workshop extension for Visual Studio Code enhances the editor with features like live preview, auto-compilation, and intelligent autocomplete, making it a popular choice for developers integrating LaTeX into broader coding workflows.[74] TeX Live serves as a cross-platform distribution bundle for LaTeX, offering comprehensive support for Unix-like systems, Windows, and macOS with annual releases that include updated packages, fonts, and binaries to ensure compatibility across diverse environments. TeX Live 2025, released in September 2025, includes the LaTeX kernel update from June 2025 with improvements in performance and accessibility, such as enhanced tagged PDFs for screen readers.[54][16][34] In contrast, MiKTeX is tailored primarily for Windows users, providing an on-demand package installation system that automatically downloads and installs required components during compilation, reducing initial setup overhead.[55] Auxiliary tools like BibDesk streamline bibliography management for LaTeX users on macOS by serving as a graphical BibTeX editor that allows importing, organizing, and exporting references with support for formatted previews and integration with LaTeX documents. LyX offers a WYSIWYM (What You See Is What You Mean) interface that abstracts LaTeX syntax while generating underlying code, enabling users to focus on document structure through a graphical layout without direct command editing.[75] As of 2025, AI-assisted integrations such as GitHub Copilot have gained traction for LaTeX code generation, providing inline suggestions for commands, templates, and even full sections within compatible editors like VS Code to accelerate authoring.[76] Workflow enhancers like Git enable version control for LaTeX projects by tracking changes in .tex files, facilitating branching for collaborative revisions and merging without conflicts in text-based content.Compatibility and Conversion
LaTeX's input compatibility varies across its underlying engines. The traditional pdfLaTeX engine relies on legacy 7-bit character encoding, limiting it to 256-character font files and requiring inputenc or manual encoding declarations for non-ASCII characters, which can complicate Unicode handling.[77][78] In contrast, XeLaTeX and LuaTeX provide native Unicode support, enabling direct processing of UTF-8 input without additional encoding packages and allowing seamless integration of international scripts through system fonts.[79][80][81] For output conversion, several tools facilitate transforming LaTeX documents into other formats. Pandoc serves as a versatile converter, supporting bidirectional translation between LaTeX and formats like Markdown, HTML, and Docx while preserving mathematical expressions via MathML or similar embeddings.[82] LaTeXML converts LaTeX to HTML or XML, emphasizing semantic markup for web accessibility and scholarly publishing, often outperforming simpler tools in handling complex layouts.[83] Detex, a lightweight utility, strips LaTeX markup to produce plain text output, primarily for tasks like spell-checking or indexing without rendering. Cross-engine support introduces variances, particularly in font handling. PdfTeX offers limited support for modern font formats, restricting users to Type 1 or legacy TrueType subsets and excluding native OpenType features like advanced glyph substitution. LuaTeX, however, integrates robust OpenType handling through its Lua scripting layer, enabling features such as variable fonts and complex script shaping directly from system-installed files via the fontspec package.[84][85][81] These differences can affect portability, as documents optimized for LuaTeX may require adjustments when compiled with pdfTeX due to incompatible font metrics. LaTeX has inherent limitations in direct support for right-to-left (RTL) languages like Arabic or Hebrew, where pdfLaTeX struggles with bidirectional text flow and requires extensive workarounds. Even with XeLaTeX or LuaTeX, core support is absent without packages such as polyglossia, which extends babel-like functionality for multilingual RTL typesetting but still demands careful font and script configuration to avoid alignment issues.[80][86] As of 2025, advancements in EPUB export have enhanced LaTeX's interoperability with digital publishing. The tex4ebook bundle, built on TeX4ht, now offers improved conversion to EPUB 3 formats, including better handling of multimedia, hyperlinks, and accessibility features like MathML for equations, making it suitable for reflowable ebooks from complex LaTeX sources.[87][88]Distribution and Community
Licensing and Distribution
LaTeX is distributed under the LaTeX Project Public License (LPPL), a free software license introduced in 1999 with version 1.2 and currently at version 1.3c.[89][90] The LPPL permits users to copy, distribute, and modify the software, provided that the original name is preserved unless substantial changes are made that alter its core functionality.[89] In contrast, the underlying TeX system, developed by Donald Knuth, is released into the public domain, allowing unrestricted use and modification without licensing restrictions.[91] The primary distribution channel for LaTeX and related TeX materials is the Comprehensive TeX Archive Network (CTAN), a centralized repository hosted at ctan.org and mirrored at numerous sites worldwide to ensure global accessibility and redundancy.[92][93] A key distribution is TeX Live, a free, multi-platform collection that includes the LaTeX kernel, packages, fonts, and tools, supporting Unix-like systems, Windows, and macOS.[54] TeX Live is updated annually, with the 2025 release issued on March 8, 2025, incorporating ongoing security patches and enhancements through its package manager.[54] While the core LaTeX software incurs no fees, commercial services offer paid support and advanced features; for instance, Overleaf provides a Pro subscription for enhanced collaboration tools, increased storage, and priority assistance.[94] To maintain compatibility and avoid confusion, the LPPL requires derivative works to adopt distinct names, such as "fooLaTeX," when modifications are significant enough to warrant rebranding.[89]Version History
LaTeX 2.09, the original widely available version released in 1985, served as the foundational implementation of the LaTeX typesetting system but was inherently non-extensible, limiting its adaptability for future enhancements without significant rewrites.[95] This version relied on a fixed structure, making it suitable for basic document preparation in academic and scientific contexts during the 1980s and early 1990s, yet it lacked mechanisms for modular package loading or kernel updates.[96] In June 1994, LaTeX2e was introduced as a major revision, replacing LaTeX 2.09 and establishing the current kernel architecture that remains in use today.[57] Key innovations included the\NeedsTeXFormat command to specify required format versions, enabling better dependency management, and a design that supported ongoing maintenance through periodic releases rather than full overhauls.[97] Since its inception, LaTeX2e has followed a biannual release cycle (June and November) starting from 2015, with each update dated nominally (e.g., 2025/11/01 for the latest as of November 2025) and often including patch levels for minor fixes.[97] For instance, the 2025/06/01 release addressed LuaTeX-specific issues by integrating automatic MathML generation for tagged mathematics, improving accessibility in PDF 2.0 output while maintaining compatibility with earlier engines.[98]
Developments under the LaTeX3 umbrella, initiated as an experimental extension to the core system, have progressively integrated advanced features into LaTeX2e.[27] Notable progress includes the 2020 incorporation of the L3 programming layer into the kernel for enhanced modularity and the introduction of experimental tagging mechanisms in 2023–2025 to support accessible PDF output via commands like \DocumentMetadata{... tagging = on}. These tags, currently optional and engine-dependent (e.g., via LuaTeX), aim to automate structure for screen readers without disrupting existing workflows.[34] Earlier LaTeX3 efforts, such as hook management in 2020, further underscore the shift toward a more extensible foundation.
To ensure backward compatibility with legacy documents, LaTeX2e provides modes like \usepackage{latex209}, which emulates the behavior of the 2.09 version by loading a dedicated configuration file and suppressing newer features.[99] The latexrelease package, added in 2015, allows users to emulate specific past or future kernel versions, facilitating smooth transitions during updates.
Over time, LaTeX2e has deprecated several obsolete commands to promote robust coding practices, such as phasing out \bf in favor of \textbf for semantic bold formatting, deprecated and removed from the kernel since LaTeX2e in 1994 with warnings issued when used.[34] Similar deprecations, including the retirement of legacy mark interfaces in 2025, consolidate older code paths into modern equivalents, reducing maintenance overhead while preserving compatibility options.[98]