tex2typst
JavaScript library for conversion between TeX/LaTeX and Typst math formula code.
Despite the name tex2typst
due to the initial goal of converting TeX to Typst, the library can also convert Typst to TeX since version 0.3.0.
Try it online
A Web UI wrapper is available at https://qwinsi.github.io/tex2typst-webapp/.
Installation
Installing it in a Node.js project
npm install tex2typst
Or just loading it in a web page
<script src="https://cdn.jsdelivr.net/npm/tex2typst@0.3.0-beta-5/dist/tex2typst.min.js"></script>
<script src="https://unpkg.com/tex2typst@0.3.0-beta-5/dist/tex2typst.min.js"></script>
Replace 0.3.0-beta-5
with the latest version number in case this README is outdated.
Usage
import { tex2typst, typst2tex } from 'tex2typst';
let tex = "e \overset{\text{def}}{=} \lim_{{n \to \infty}} \left(1 + \frac{1}{n}\right)^n";
let typst = tex2typst(tex);
console.log(typst);
let tex_recovered = typst2tex(typst);
console.log(tex_recovered);
If you are using the library in a web page via a <script>
tag, you don't need the line of import
, function tex2typst
and typst2tex
should be available in the global scope.
Open-source license
GPL v3. See LICENSE for details.
Contributing
Feel free to open an issue or submit a pull request.