Crates.io | tex-fmt |
lib.rs | tex-fmt |
version | 0.4.6 |
source | src |
created_at | 2024-04-27 18:47:11.770883 |
updated_at | 2024-10-21 15:49:35.291615 |
description | LaTeX formatter written in Rust |
homepage | |
repository | https://github.com/WGUNDERWOOD/tex-fmt |
max_upload_size | |
id | 1222809 |
size | 63,460 |
An extremely fast LaTeX formatter written in Rust.
Input | Output |
|
|
.tex
, .bib
, .cls
, and .sty
Install the stable release with
cargo install tex-fmt
Install from GitHub with
cargo install --git "https://github.com/wgunderwood/tex-fmt"
Install from nixpkgs into a temporary shell with
nix-shell -p tex-fmt
Build from source using flakes with
nix build "github:wgunderwood/tex-fmt"
Add to your NixOS installation with
environment.systemPackages = [
pkgs.tex-fmt
];
Install from the Arch User Repository. For example, using the yay AUR helper:
yay -S tex-fmt
Install using Homebrew with
brew install tex-fmt
Binaries for various platforms are available on the GitHub releases page.
Integration with VS Code is provided by the LaTeX Workshop extension. You will need to first install tex-fmt through one of the above methods.
tex-fmt file.tex # format file.tex and overwrite
tex-fmt --check file.tex # check if file.tex is correctly formatted
tex-fmt --print file.tex # format file.tex and print to STDOUT
tex-fmt --keep file.tex # do not wrap long lines
tex-fmt --stdin # read from STDIN and print to STDOUT
tex-fmt --help # view help information
Ending a source line with % tex-fmt: skip
disables formatting for that line.
To disable the formatter for a block, use % tex-fmt: off
and % tex-fmt: on
.
\documentclass{article}
\begin{document}
This line is skipped % tex-fmt: skip
% tex-fmt: off
These lines are also
not formatted or wrapped
% tex-fmt: on
\end{document}
Verbatim environments including verbatim
, Verbatim
, lstlisting
and minted
are automatically skipped.
When formatting all of the test cases, tex-fmt is over a thousand times faster than latexindent.
Files | Lines | Size | tex-fmt | latexindent | latexindent -m |
---|---|---|---|---|---|
49 | 94k | 3.5M | 0.052s | 99s [x1904] | 132s [x2538] |
Please feel free to open an issue or submit a pull request,
including as much information as you can. Documentation of internals
can be accessed by cloning this repository and running cargo doc
.
Alternatively, you can Buy Me a Coffee!
latexindent. Perl script, many configuration options, slow on large files
LaTeXTidy. Perl script, download links seem to be broken
latex-pretty. Browser-based, uses latexindent as the backend
latexformat.com. Browser-based
texpretty. C program which works sometimes and appears to be fast
latex-editor. Browser-based
LaTeXFmt. Vim plugin, does not apply indentation
latex-formatter. Visual Studio plugin, uses latexindent as the backend