Open-source project
mitex-rs/mitex avatar
mitex-rs/mitex

MiTeX: reading LaTeX inside Typst without converting it by hand

LaTeX support for Typst, powered by Rust and WASM. https://mitex-rs.github.io/mitex/

638 stars36 forksRustApache-2.0

At a glance

What is it?
MiTeX is a Rust and WebAssembly project that parses LaTeX into an abstract syntax tree and turns it into Typst code, so you can write LaTeX inside a Typst document and keep the display consistent with what LaTeX would produce. It ships as a Typst package, a CLI and a browser tool.
Who is it for?
MiTeX suits Typst authors who need to reuse LaTeX fragments, especially maths written by someone else, and who want the converted output to look like LaTeX rather than like a readable approximation.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 12 days ago.
What is it written in?
Mainly Rust, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.

Editorial analysis

MiTeX parses LaTeX into an AST and emits Typst code

MiTeX processes LaTeX code into an abstract syntax tree, transforms that tree into Typst code, and then evaluates the code into Typst content with an eval function. That three step description is the architecture in full, and it explains the project's behaviour better than any feature list. The parsing stage is separate from the transformation stage, and the AST in between means the same parser can serve multiple back ends. The README credits the most complex part of that work, developing the parser that generates the AST, to one named contributor. The repository layout matches the pipeline. There is a crates/ directory holding the workspace members, and the workspace dependency list in Cargo.toml names them explicitly: mitex-spec for the command specifications, mitex-glob, mitex-lexer, mitex-parser, mitex itself, and mitex-spec-gen for generating specifications. The result is a Rust workspace with edition 2021 and a stated rust-version of 1.74. The project is also compiled to WebAssembly, which is what lets the same converter run inside Typst itself rather than only as a command line program.

Inside Typst you get mi, mitex and mitext, not one function

As a Typst package, MiTeX exposes four entry points and the difference between them matters. The `mi` function renders an inline LaTeX equation. The `mitex` function, and an alias `mimath`, renders a block LaTeX equation, and it accepts options such as numbering and supplement. The `mitext` function renders LaTeX text. There is also `mitex-convert`, which converts LaTeX code into Typst code in string form, which is what you want when you need the converted source rather than rendered output. The README also notes that setting the equation numbering in Typst directly, with #set math.equation(numbering: "(1)"), is valid for MiTeX. The example shipped in the repository shows the intended usage, importing the package at a pinned version and using inline and block forms:

typst
#import "@preview/mitex:0.2.7": *

Write inline equations like #mi(`x`).

Also block equations (this case is from #text(blue.lighten(20%), link("https://katex.org/")[katex.org])):

#mitex(`
  \newcommand{\f}[2]{#1f(#2)}
  \f\relax{x} = \int_{-\infty}^\infty
    \f\hat\xi\,e^{2 \pi i \xi x}
    \,d\xi
`)

We also support text mode (in development):

#mitext(`
  \iftypst
    #set math.equation(numbering: "(1)", supplement: "equation")
  \fi

  \section{Title}

  A \textbf{strong} text, a \emph{emph} text and inline equation $x + y$.

  Also block \eqref{eq:pythagoras}.

  \begin{equation}
    a^2 + b^2 = c^2 \label{eq:pythagoras}
  \end{equation}
`)

The import line pins a specific package version, which matters when the package is still moving.

The CLI compiles a .tex file straight to a .typ file

The command line tool is the second way in, and it is the right choice when you are converting a file rather than embedding a fragment. Installation is a cargo install of the mitex-cli crate straight from the git repository, which the README describes as the nightly version. The command is `cargo install --git https://github.com/mitex-rs/mitex mitex-cli`, and it can be run as-is since the repository URL is part of the documented line.

The usage is a single subcommand with an optional output path:

bash
mitex compile main.tex
# or (same as above)
mitex compile main.tex mitex.typ

Writing the output to standard output when no second path is given means the result can be piped, and naming an output file writes it there. The CLI is built with clap, and the workspace dependency list shows clap with the derive, env, unicode and wrap_help features, plus clap_complete and a fig completion generator and clap_mangen for the man page. That last entry matters for a tool meant to be run on a terminal, since the man page is generated rather than hand maintained. vergen is also a dependency, with build, cargo, git, gitcl and rustc features, which is the usual way to embed build and version information in a binary at compile time, so `mitex --version` reports a value tied to the checkout rather than a constant in the source.

A browser build covers the online converter and the Underleaf proof of concept

Because the core is compiled to WebAssembly, MiTeX runs in the browser as well. The README describes an online math converter that converts LaTeX equations to Typst equations in the web through wasm, hosted under the project's GitHub Pages site. The second browser tool is Underleaf, described as a proof of concept online TeX editor built to show the conversion speed in text mode. The way it works is specific: it loads files from a git repository and then runs typst compile in the browser, so the preview updates as you type. That is a meaningful demonstration rather than a screenshot, because it exercises the whole chain of parse, transform, evaluate and render inside a browser tab. The homepage for this repository points at that Underleaf page, which suggests the author considers the interactive demo the entry point for most visitors. The limitations of the demo follow from its stated purpose. It is labelled a proof of concept, it is scoped to showing conversion speed in text mode, and it sources its files from a git repository rather than from local disk or an upload.

The implemented feature list is where the boundaries are

The README keeps a checkbox list of implemented features, and reading it as a contract is more useful than the marketing framing around it. User-defined TeX macro commands are implemented, including the standard newcommand form. LaTeX equations are supported, including colouring commands such as color and textcolor, and environments including aligned, matrix and cases. Basic text mode support is marked as implemented with a note that you can use it to write LaTeX drafts, and within it there is support for section, textbf and emph, for inline and block maths, for ref, eqref and label, for itemize and enumerate, and for figure, table and tabular. Below that sit three features marked as not yet implemented. Passing a command specification to the MiTeX plugin dynamically is one, which would let you define a Typst function and then call it from LaTeX. Package support is another, meaning you would tell MiTeX to use a list of packages. Better text mode support, naming figure, algorithm and description environments, is the third. The README is candid about why the last two are still open, saying they need a well structured architecture for the text mode along with detailed work, and that there are not yet very clear ideas. It asks for discussion in the issues or pull requests in place of a finished design.

MiTeX and texmath disagree about what correct output means

The README sets out the difference from texmath, also known as pandoc, and the disagreement is about output format rather than about coverage. MiTeX is described as focusing on rendering LaTeX content correctly within Typst, using WASM and Typst to achieve results essentially consistent with LaTeX display. texmath is described as aiming to be a general purpose converter that generates strings that are more human readable. The examples make the consequence concrete. MiTeX transforms \frac{1}{2}_3 into frac(1, 2)_3, while texmath converts the same input into 1 / 2_3, and the README states that the latter's display is not entirely correct while the former ensures consistency in display. A second example shows MiTeX turning (\frac{1}{2}) into \(frac(1, 2)\) rather than (frac(1, 2)), avoiding automatic Left and Right delimiters to stay consistent with LaTeX rendering. So the choice is between a human friendly intermediate form and one that renders correctly. If your goal is a diffable, editable conversion of a whole document, the human readable form is easier to work with. If the goal is a document that looks like the LaTeX original, MiTeX's approach is the relevant one, and the README puts it plainly, you can write LaTeX content in Typst without manual conversion.

Special commands are handled by overriding the mitex function

Adding your own commands has two documented routes. The first is for commonly used commands: if a builtin or frequently used command is missing, the README points you to the contributing guide, including an anchor for adding missing TeX commands, and to the issue tracker for reporting them. The second route is for special commands and preambles of your own, and the mechanism is a Typst level override rather than a change to the parser. You define the command with newcommand or newenvironment in your own document and then override the mitex function:

typst
  #let mitex = (content, ..args) => mitex.with(..args)({
    \newcommand{\f}[2]{#1f(#2)}
    content.text
  })

The override injects your preamble before the content and then renders the content as text. You then use the command in your Typst source:

typst
  #show raw.where(lang: "mitex"): mitex
  \f\relax{x} = \int_{-\infty}^\infty
    \f\hat\xi\,e^{2 \pi i \xi x}
    \,d\xi

mitex \f\relax{x} = \int_{-\infty}^\infty \f\hat\xi\,e^{2 \pi i \xi x} \,d\xi

code

The show rule attaches the overridden function to raw blocks tagged with the mitex language. This is the practical route for a document that needs one unusual macro, and it works today because user-defined commands are on the implemented list. The dynamic specification feature listed as not implemented would have made this kind of thing work without overriding the function at all. The licence is Apache-2.0, and the workspace metadata records the same licence, with the project version at 0.2.7 and releases 0.2.7 on 2026-04-07 and 0.2.6 on 2026-04-04. The last push to the repository was on 2026-10-11, so work continues between releases.

Editorial conclusion

MiTeX suits Typst authors who need to reuse LaTeX fragments, especially maths written by someone else, and who want the converted output to look like LaTeX rather than like a readable approximation. It is the wrong tool for long text mode documents, since the README describes basic text mode support as still in development with better text mode work listed as not yet implemented, and it is the wrong tool if you need the full LaTeX package set, because package support is an unchecked box. Verify first that the commands your document relies on are in the implemented feature list, that the Typst package version you import matches the release you are reading about, and that the parser handles the constructs in your source LaTeX before you migrate a whole document.

Frequently asked questions

How do I use MiTeX inside a Typst document?

Import the package, for example #import "@preview/mitex:0.2.7": *, then use mi for an inline equation, mitex or mimath for a block equation, and mitext for LaTeX text. The mitex-convert function returns the converted Typst code as a string.

How do I install the MiTeX command line tool?

The README documents installing the nightly version with cargo install --git https://github.com/mitex-rs/mitex mitex-cli. You then compile a file with mitex compile main.tex, optionally naming an output file.

How does MiTeX differ from texmath?

MiTeX targets display consistency with LaTeX inside Typst, while texmath aims to be a general purpose converter producing more human readable strings. For example MiTeX converts \frac{1}{2}_3 into frac(1, 2)_3 where texmath produces 1 / 2_3.

Is text mode support complete in MiTeX?

Not fully. The README lists basic text mode support as implemented for writing LaTeX drafts, with section, textbf, emph, refs, itemize, enumerate, figure, table and tabular covered, while better text mode support for figure, algorithm and description environments remains on the list of features to implement.

Official sources

  1. License: Apache-2.0
  2. mitex-rs/mitex on GitHub
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/mitex-rs-mitex.svg)](https://hysenlabs.com/projects/mitex-rs-mitex)

Was this useful?