LinuxCommandLibrary

tex-fmt

Format TeX files

TLDR

Format a file, overwriting the original

$ tex-fmt [path/to/file.tex]
copy

Check if a file is correctly formatted
$ tex-fmt --check [path/to/file.tex]
copy

Format a file read from stdin and print to stdout
$ cat [path/to/file.tex] | tex-fmt --stdin
copy

SYNOPSIS

tex-fmt [options] <format_name>

PARAMETERS

<format_name>
    The symbolic name of the TeX format to be created or updated (e.g., plain, latex). This refers to the corresponding source file (e.g., plain.tex, latex.ltx).

-v, --verbose
    Displays detailed information about the compilation process, including TeX engine output.

-u, --update
    Updates the format file only if its source (e.g., plain.tex) is newer than the existing .fmt file.

-f, --force
    Forces recompilation of the format file, even if it appears up-to-date or newer than its source.

-o <output_dir>, --output-directory=<output_dir>
    Specifies an alternative directory for the generated .fmt file, overriding the default TeX output location.

DESCRIPTION

The tex-fmt command is conceptually designed to compile TeX source files into precompiled format files (e.g., plain.fmt, latex.fmt). These .fmt files significantly speed up TeX processing by loading a pre-initialized state of the TeX engine, including macros and definitions. While tex-fmt itself is not a universally standardized standalone binary in modern TeX distributions (like TeX Live, where fmtutil is the primary tool), its name implies a utility for handling TeX formats. It would typically automate the process of invoking the TeX engine with the -ini (initialization) option on a format source file, followed by a \dump command, to produce the corresponding .fmt file. It serves as an abstraction for a fundamental TeX operation.

CAVEATS

The command tex-fmt is not a widely distributed or standardized standalone executable in most modern Linux distributions or TeX Live installations. Its functionality is typically provided by more comprehensive tools such as fmtutil or mktexfmt, which offer more robust and configurable format management. If tex-fmt exists on a specific system, it is likely a local script or an alias for one of these standard tools, or a remnant from older TeX setups. Users should generally rely on fmtutil for managing TeX formats.

FORMAT FILES (.FMT)

TeX format files are precompiled versions of a TeX engine's state, containing loaded macros, fonts, and internal settings. They are generated from .tex source files (e.g., plain.tex for plain.fmt) using the TeX engine's initialization mode (tex -ini). Using a .fmt file drastically reduces the startup time for large documents by avoiding the need to parse and load all standard macros from scratch for every run.

COMPILATION PROCESS

A typical internal process for tex-fmt plain would involve locating plain.tex (or plain.ltx for LaTeX), then executing tex -ini plain.tex \dump, resulting in plain.fmt being created in an appropriate TeX tree directory. The specific location is managed by the TeX File System (TDS) hierarchy and typically resolved by kpsewhich.

HISTORY

The concept of a tex-fmt utility likely emerged from the need to simplify the creation of TeX format files, which historically involved direct invocation of tex -ini followed by \dump. As TeX distributions grew more complex, simple scripts for this purpose evolved into more sophisticated tools. In modern TeX Live, fmtutil became the de facto standard for building and maintaining format files, incorporating features like dependency tracking and configuration management, effectively superseding simpler tex-fmt concepts or scripts.

SEE ALSO

tex(1), fmtutil(1), kpsewhich(1)

Copied to clipboard