tex-fmt 0.4.0

LaTeX formatter written in Rust
tex-fmt-0.4.0 is not a library.
Visit the last successful build: tex-fmt-0.5.7

tex-fmt

CI crates.io license: MIT

An extremely fast LaTeX formatter written in Rust.

\documentclass{article}

\begin{document}

\begin{itemize}
\item Lists with items
over multiple lines
\end{itemize}

\begin{equation}
E = m c^2
\end{equation}

\end{document}
\documentclass{article}

\begin{document}

\begin{itemize}
  \item Lists with items
    over multiple lines
\end{itemize}

\begin{equation}
  E = m c^2
\end{equation}

\end{document}
  • ⚡ Extremely fast run-time performance
  • 🔧 No configuration necessary
  • 📟 Command-line interface
  • 📜 Handles LaTeX file types .tex, .bib, .cls, and .sty
  • 🦀 Written entirely in safe Rust

Installation

Cargo

# install stable release
cargo install tex-fmt

# install from github
cargo install --git "https://github.com/wgunderwood/tex-fmt"

Nix

nix build "github:wgunderwood/tex-fmt"

Usage

tex-fmt file.tex        # format file.tex and overwrite
tex-fmt -c file.tex     # check if file.tex is correctly formatted
tex-fmt -p file.tex     # format file.tex and print to STDOUT
tex-fmt -k file.tex     # keep lines, do not wrap
tex-fmt -h              # view help information

Performance

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.096s 97s [x1001] 125s [x1288]

Limitations

  • Semantic parsing of LaTeX code not conducted
  • No linting or correction of syntax errors
  • Customization via configuration files not supported
  • Compliance with existing formatting guidelines not guaranteed
  • Editor integration not currently provided
  • No spelling or grammar checking

Existing tools