LaTeX2e Kernel and Core Components

repository·develop·Indexed 25 days ago

https://github.com/latex3/latex2e

Development repository for the LaTeX2e kernel and its essential core components. This bundle includes the core kernel and required packages such as amsmath, graphics, tools, cyrillic, and firstaid. It also contains the latex-lab bundle for experimental features like \DocumentMetadata and new output routines. The repository is intended for development; end-users are advised to obtain stable versions via CTAN or TeX distributions like TeX Live and MiKTeX.

Tokens
11.7K
Snippets
11
Records
66
Agent score
81%

What's inside latex2e

  1. Overview of the graphics bundle packages

    develop

    The graphics bundle provides core support for color, graphics, and text manipulation in LaTeX. It includes the following packages:

    • color: Core color support
    • graphics: The original LaTeX graphics inclusion interface
    • graphicx: Extended interface for graphics inclusion
    • lscape: Production of landscape pages
    • keyval: Core key-value support for LaTeX
    • rotating: Support for rotating material
    • trig: Support for fast trigonometric calculations in TeX
    • epsfig: A legacy stub now subsumed into graphics.
  2. Overview of the LaTeX kernel bundle

    develop

    This bundle provides the core LaTeX kernel. Note that the kernel alone is not a complete LaTeX system. To have a functional minimal LaTeX environment, you must also have the following components installed:

    L3 Programming Layer Components:

    • l3kernel (L3 programming layer)
    • l3backend (L3 backend interfaces)
    • unicode-data (L3 unicode support)

    Required Packages:

    • tools (Essential tools)
    • graphics (Core graphics and color support)
    • amsmath (Key mathematics support)
    • firstaid (First aid for external packages)
  3. Experimental features in LaTeX laboratory

    develop

    The latex-lab bundle currently provides support for the following experimental features:

    • \DocumentMetadata support: Provides the real payload for the \DocumentMetadata command introduced in the kernel (as of 2021/12). This is used extensively for the LaTeX tagging project.
    • New output routine code: Includes experimental implementations of new output routines, such as the first implementation of footnote support.
  4. What is LaTeX2e temporary first aid?

    develop
    LaTeX2e temporary first aid is a mechanism used during transition periods when a new LaTeX release updates internal commands. If external packages or classes rely on these internal commands and have not yet been updated by their maintainers, they may fail. This 'first aid' code is provided as a separate file external to the base bundle to allow for rapid updates and fixes without requiring a full new LaTeX2e release to be uploaded to CTAN.
  5. What is the LaTeX laboratory bundle?

    develop

    The latex-lab bundle contains optional, experimental files that are loaded by the LaTeX kernel when specific conditions are met. It serves as a staging area for new features that are still under development, allowing for intermediate releases without modifying the core production kernel.

    Key characteristics:

    • Transparent usage: The files are not intended to be loaded directly by users as packages (e.g., via \usepackage). Instead, they are loaded automatically by kernel commands.
    • Experimental nature: The code is primarily used for testing new functionality, such as the tagging project or new output routines.
    • Lifecycle: Once the code in this bundle is finalized and tested, it will be moved into the main LaTeX kernel, and the corresponding file in this bundle will be removed.
  6. What is extbackslash m@th and how is it used in the LaTeX core?

    develop

    In the LaTeX2e kernel and related packages (like amsmath), \m@th is a low-level command used to manage math mode spacing and styles, specifically when embedding math inside other constructs like \hbox, \vbox, or \mbox.

    Its primary roles include:

    1. Resetting Math Surroundings: It is often defined as \def\m@th{\mathsurround\z@}, which effectively cancels out any user-defined \mathsurround (the space added around inline math) to ensure that math embedded in boxes has predictable, zero-padding spacing.
    2. Ensuring Math Mode: It is frequently used inside math delimiters (e.g., $\m@th ...$) to ensure that the math environment is correctly initialized within a box or a specialized alignment structure.
    3. Style Consistency: It is used alongside math styles like \displaystyle, \textstyle, \scriptstyle, and \scriptscriptstyle to ensure that math elements (like subscripts, superscripts, or operators) are rendered with the correct size and spacing when they are part of a larger layout component (like a matrix, a fraction, or a decorated symbol).
  7. Requirements for the LaTeX kernel

    develop

    To run the LaTeX kernel, your TeX engine must support:

    1. e-TeX extensions: Finalized in the late 1990s and available in all modern TeX-derived engines.
    2. pdfTeX additions: A set of common post-e-TeX extensions available in all modern TeX engines.
  8. Identify the 'required' LaTeX packages

    develop

    The LaTeX team defines a set of 'required' packages that any package developer can assume are present in any standard LaTeX distribution. If you are writing a LaTeX package, you are entitled to use these packages without requiring users to install them separately.

    The current 'required' set includes:

    • amsmath: Mathematical support (maintained by the LaTeX team).
    • cyrillic: Standard support for Cyrillic alphabet fonts.
    • graphics: Standard LaTeX graphics and color support.
    • tools: Basic LaTeX utility tools.
    • babel: Multilingual typesetting support.

    Note: While babel is part of the required set, it is maintained in its own repository and should be reported via its specific issue tracker.

  9. Common patterns for using \textbackslash m@th in math construction

    develop

    When building custom math symbols or complex layouts, \m@th is used to stabilize the math environment. Common patterns found in the core code include:

    • Embedding math in boxes: \hbox{$\m@th ...$} or \vbox{\m@th\ialign{...}} to ensure math inside a box doesn't inherit unwanted surrounding space.
    • Decorated symbols: Using \m@th within \mathop or \vcenter to ensure operators like \lim or \underbrace render correctly.
    • Math styles in boxes: Combining \m@th with specific styles, such as $\m@th\displaystyle ...$ or $\m@th\scriptstyle ...$, to force a specific math size inside a non-math context.
  10. Use hooks instead of redefining \@makecol

    develop

    When extending or modifying LaTeX column building behavior, avoid direct redefinitions of \@makecol. Instead, use the provided hooks to ensure compatibility with tagging and the new Output Routine (OR).

    Depending on your needs, use:

    • {build/column/before}: To execute code before the column is built.
    • {build/column/after}: To execute code after the column is built.

    Directly overwriting \@makecol (as seen in many legacy packages) often breaks tagging support or conflicts with the internal LaTeX Output Routine.

  11. Use the {cmd/@makecol/after} hook for command-specific overrides

    develop
    For packages like lineno.sty that swap in their own command definitions (e.g., \if@twocolumn \let\@makecol\LN@makecol \fi), the preferred mechanism for handling these overrides is the {cmd/@makecol/after} hook. This is intended to replace manual command swapping, provided that the class (like memoir or revtex) does not also install its own command override.
  12. Understand how packages alter \@footnotetext

    develop

    In LaTeX2e, the internal command \@footnotetext is responsible for typesetting the text of a footnote at the bottom of a page. Many packages redefine this command to implement specialized footnote behaviors, such as changing line spacing, adjusting margins, handling nested contexts, or placing footnotes in the margin instead of the bottom.

    When developing or debugging packages, be aware that redefining \@footnotetext can cause conflicts if multiple packages attempt to do so. A common pattern for safe redefinition is to save the original command (e.g., \let\oldfootnotetext=\@footnotetext) and then call it within the new definition.