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] [file ...]

PARAMETERS

-n
    No-op mode. Print what would be changed, but do not actually modify the files.

-w
    Overwrite files directly. By default, tex-fmt writes to standard output.

-config
    Specify a configuration file to use. If not specified, tex-fmt will search for a .tex-fmt.toml file in the current directory and its parent directories.

-version
    Print the version and exit.

-help
    Show help message and exit.

DESCRIPTION

The tex-fmt command is a command-line tool used for automatically formatting TeX and LaTeX source code. Its primary goal is to improve readability and maintainability of TeX/LaTeX documents by applying consistent indentation, spacing, and line breaks according to predefined or user-configured rules.

It aims to achieve uniform styling across projects and among multiple collaborators, reducing visual clutter and simplifying code review. The tool can be customized to adhere to specific coding style guidelines, making it adaptable to various project requirements. tex-fmt is particularly helpful for managing large and complex TeX/LaTeX documents where manual formatting can become tedious and error-prone. It helps ensure a consistent and professional appearance across all project documents. tex-fmt does not interpret latex code, therefore, it does not provide error reports.

CAVEATS

tex-fmt relies on a configuration file (.tex-fmt.toml) for its formatting rules. It is important to have a well-defined configuration for consistent results.

tex-fmt can not fix errors in the latex file.

CONFIGURATION

The behaviour of tex-fmt is controlled by a configuration file, typically named .tex-fmt.toml. This file specifies formatting rules such as indentation, line wrapping, and spacing. The tool will automatically search for the .tex-fmt.toml file.
You can specify your own config file location with the -config option.

HISTORY

The tex-fmt tool emerged as a necessity for maintaining consistent code style in LaTeX projects. As LaTeX documents grew in complexity, the manual application of formatting rules became increasingly difficult and time-consuming. tex-fmt was developed to automate this process, providing a reliable and configurable solution for enforcing coding standards. The tool has evolved with input from the LaTeX community, incorporating features and options to address a wide range of formatting preferences and project requirements. Its development focuses on providing flexibility and ease of integration into existing LaTeX workflows.

SEE ALSO

latex(1), pdflatex(1)

Copied to clipboard