Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/unpredictability/tex2typst-rs
A Rust library that converts TeX code to Typst code.
https://github.com/unpredictability/tex2typst-rs
convert converter formula latex math parser rust typst
Last synced: about 11 hours ago
JSON representation
A Rust library that converts TeX code to Typst code.
- Host: GitHub
- URL: https://github.com/unpredictability/tex2typst-rs
- Owner: Unpredictability
- License: gpl-3.0
- Created: 2025-01-28T12:31:17.000Z (18 days ago)
- Default Branch: main
- Last Pushed: 2025-02-13T07:20:02.000Z (2 days ago)
- Last Synced: 2025-02-13T07:30:17.804Z (2 days ago)
- Topics: convert, converter, formula, latex, math, parser, rust, typst
- Language: Rust
- Homepage: https://crates.io/crates/tex2typst-rs
- Size: 185 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tex2typst-rs
A Rust library that converts TeX code to Typst code.# 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:
```latex
\overrightarrow{P M}=(3-x-y) \overrightarrow{P A}+x \overrightarrow{P B}+(y-2) \overrightarrow{P C}
```[`mitex`](https://crates.io/crates/mitex) gives the output:
```typst
arrow(P M )= \(3 - x - y \) arrow(P A )+ x arrow(P B )+ \(y - 2 \) arrow(P C )
````tex2typst-rs` gives the output:
```typst
arrow(P M) =(3 - x - y) arrow(P A) + x arrow(P B) +(y - 2) arrow(P C)
```# Usage
See the [documentation](https://docs.rs/tex2typst-rs) for more details.
```Rust
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:
```typst
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](https://github.com/qwinsi/tex2typst).