tex-fmt

Fast LaTeX source code formatter

TLDR

Format file
$ tex-fmt [document.tex]
Format in place
$ tex-fmt -w [document.tex]
Check formatting
$ tex-fmt --check [document.tex]
Format from stdin
$ cat [document.tex] | tex-fmt
With config
$ tex-fmt -c [tex-fmt.toml] [document.tex]

SYNOPSIS

tex-fmt [-w] [--check] [-c config] [options] files

DESCRIPTION

tex-fmt is a fast LaTeX source code formatter written in Rust that standardizes indentation and whitespace in .tex files. It ensures consistent formatting across documents and teams by applying configurable indentation rules to LaTeX environments, commands, and structures.The -w flag writes changes in place, while --check mode verifies formatting without modifying files, making it suitable for CI pipelines. Configuration can be provided via a TOML file to customize indentation width, tab handling, and other style preferences.

PARAMETERS

-w

Write in place.
--check
Check only.
-c FILE
Config file.
--stdin
Read stdin.
--tabsize N
Tab size.

INSTALL

sudo apt install tex-fmt
brew install tex-fmt
nix profile install nixpkgs#tex-fmt

CAVEATS

LaTeX specific. May break manual formatting. Test before use.

HISTORY

tex-fmt is a fast LaTeX formatter written in Rust for consistent document formatting.

SEE ALSO

latexindent(1), latex(1), pdflatex(1)