tex2typst-rs

Crates.iotex2typst-rs
lib.rstex2typst-rs
version
sourcesrc
created_at2025-01-29 06:58:49.701624
updated_at2025-02-06 09:50:28.341136
descriptionConverts LaTeX math to Typst math
homepage
repositoryhttps://github.com/Unpredictability/tex2typst-rs
max_upload_size
id1534454
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Jamie (Unpredictability)

documentation

README

tex2typst-rs

A Rust library that converts TeX code to Typst code.

Crate Documentation

Aim of this project

There exist some other libraries that convert LaTeX (especially LaTeX math) to other languages. However, the result may not be visually pleasing or easy to read. This project aims to convert LaTeX to idiomatic Typst code, which can be very easily read and edited.

For comparison, for this LaTeX input:

\overrightarrow{P M}=(3-x-y) \overrightarrow{P A}+x \overrightarrow{P B}+(y-2) \overrightarrow{P C}

mitex gives the output:

arrow(P  M )= \(3 - x - y \) arrow(P  A )+ x  arrow(P  B )+ \(y - 2 \) arrow(P  C )

tex2typst-rs gives the output:

arrow(P M) =(3 - x - y) arrow(P A) + x arrow(P B) +(y - 2) arrow(P C)

Usage

See the documentation for more details.

use tex2typst_rs::tex2typst;
use tex2typst_rs::text_and_tex2typst;

fn main() {
    let tex = r"\widehat{f}(\xi)=\int_{-\infty}^{\infty} f(x) e^{-i 2 \pi \xi x} d x, \quad \forall \xi \in \mathbb{R}";
    println!("{}", tex2typst(tex).unwrap());
    
    let mixed = r"some text and some formula: \(\frac{1}{2}\)";
    println!("{}", text_and_tex2typst(mixed).unwrap());
}

Output:

hat(f)(xi) = int_(- infty)^infty f(x) e^(- i 2 pi xi x) d x, quad forall xi in RR
some text and some formula: $1/2$

Acknowledgements

Took inspiration from tex2typst.

Commit count: 28

cargo fmt