Tylax: Open-source bidirectional LaTeX ↔ Typst converter for full documents (AST-based, CLI & WASM)

Hi everyone! :wave:

I’m excited to showcase Tylax, an open-source tool I’ve been building for bidirectional LaTeX ↔ Typst conversion.

It started as a small experiment I shared here previously (https://forum.typst.app/t/small-tool-latex-typst-converter-math-doc-tikz-cetz-experiments/7463?u=democat), and has now evolved into a full-fledged Rust project with robust AST parsing.

Why another converter?

Unlike regex-based scripts, Tylax uses full AST parsing (powered by mitex-parser and typst-syntax) to handle nested structures correctly. It handles math, tables, and even TikZ graphics with high precision.

Key Features

  • :arrows_counterclockwise: Bidirectional: Converts LaTeX to Typst AND Typst to LaTeX.
  • :triangular_ruler: Math Mode: Robust conversion of complex formulas, matrices, and cases.
  • :art: Graphics Support: Experimental TikZ ↔ CeTZ conversion! (Supports absolute/relative coords, styling, and basic shapes).
  • :bar_chart: Smart Tables: Handles \multicolumn and \multirow with cell coverage tracking.
  • :rocket: Fast & Private: Runs locally via CLI or completely in-browser via WebAssembly.

Examples

Here are some conversions showing the robustness of the parser:

1. Complex Calculus (LaTeX → Typst)

\int_{-\infty}^{\infty} \frac{\cos(kx)}{x^2 + a^2} dx = \frac{\pi}{a} e^{-|ka|}

integral_(- infinity)^(infinity) frac(cos (k x), x^(2) + a^(2)) d x = pi/a e^(- | k a |)

2. Linear Algebra (LaTeX → Typst)

\mathbf{X} = \begin{pmatrix}
x_{11} & \cdots & x_{1n} \\
\vdots & \ddots & \vdots \\
x_{m1} & \cdots & x_{mn}
\end{pmatrix} \in \mathbb{R}^{m \times n}

upright(bold(X)) = mat(delim: "(", x_(1 1), ..., x_(1 n) ;
dots.v, dots.down, dots.v ;
x_(m 1), ..., x_(m n)) in RR^(m times n)

3. Piecewise Function (Typst → LaTeX)

f(x) = cases(
  x^2 "if" x > 0,
  0 "otherwise"
)

f\left( x\right) = \begin{cases}
 x^2 \text{if} x > 0 \\
 0 \text{otherwise}
\end{cases}

4. Maxwell’s Equations (Typst → LaTeX)

nabla dot arrow(E) = rho / epsilon_0
quad
nabla times arrow(B) = mu_0 arrow(J) + mu_0 epsilon_0 (partial arrow(E)) / (partial t)

\nabla \cdot \overrightarrow{E} = \frac{\rho}{\epsilon_0} \quad \nabla \times \overrightarrow{B} = \mu_0 \overrightarrow{J} + \mu_0 \epsilon_0 \frac{(\partial \overrightarrow{E})}{(\partial t)}

Try it out

You can try the online demo directly in your browser, or install the CLI for batch processing:

cargo install tylax
t2l input.tex -o output.typ

Contributions and feedback on GitHub are very welcome. Thanks! :pray:

13 Likes