latexindent
formats LaTeX source code with consistent indentation
TLDR
Format LaTeX file
$ latexindent [document.tex]
Format and save in place$ latexindent -w [document.tex]
Format with local settings$ latexindent -l [document.tex]
Specify output file$ latexindent [input.tex] -o [output.tex]
Silence output$ latexindent -s [document.tex]
Check only (no modification)$ latexindent -c [document.tex]
SYNOPSIS
latexindent [options] file
DESCRIPTION
latexindent formats LaTeX source code with consistent indentation. It handles environments, commands, and special constructs intelligently.
The tool is configured through YAML files, allowing customization of indent size, environments, and special cases.
PARAMETERS
-w, --overwrite
Overwrite original file.-o file
Output to specific file.-l [file]
Use local settings file.-s, --silent
Silent mode.-c dir
Check mode, use directory for cruft.-m, --modifylinebreaks
Modify line breaks.-g file
Log file location.--replacement
Enable replacement mode.-y yaml
Settings in YAML format.
LOCAL SETTINGS
$ # localSettings.yaml
defaultIndent: " "
removeTrailingWhitespace: 1
noAdditionalIndent:
document: 1
defaultIndent: " "
removeTrailingWhitespace: 1
noAdditionalIndent:
document: 1
CAVEATS
Perl-based; requires Perl and YAML::Tiny. May change semantics in edge cases. Backup files created by default. Complex documents may need custom rules.
HISTORY
latexindent was written by Chris Hughes as a Perl script for formatting LaTeX code. It's included in TeX Live and is commonly used for maintaining consistent LaTeX codestyle.
