LinuxCommandLibrary

latexindent

formats LaTeX source code with consistent indentation

TLDR

Format LaTeX file

$ latexindent [document.tex]
copy
Format and save in place
$ latexindent -w [document.tex]
copy
Format with local settings
$ latexindent -l [document.tex]
copy
Specify output file
$ latexindent [input.tex] -o [output.tex]
copy
Silence output
$ latexindent -s [document.tex]
copy
Check only (no modification)
$ latexindent -c [document.tex]
copy

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
copy

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.

SEE ALSO

latex(1), latexmk(1), prettier(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community