d docmux

v0.6.0 Open source, MIT Rust + WebAssembly

Convert documents between LaTeX, Typst, Markdown and Word.

docmux is a document converter that runs in your browser. Give it a LaTeX paper and get Typst that compiles, a Word file with real equations, HTML or Markdown. Nothing is uploaded: the conversion happens on your machine.

Open the playground
paper.tex LaTeX
\newcommand{\kl}[2]{D_{\mathrm{KL}}\left(#1 \,\|\, #2\right)}

\section{Variational bound}\label{sec:bound}
For any $q(z \mid x)$, the evidence is bounded below:
\begin{equation}\label{eq:elbo}
  \log p(x) \ge \mathbb{E}_{q}\left[\log p(x \mid z)\right]
    - \kl{q(z \mid x)}{p(z)}
\end{equation}
We maximize Eq.~\eqref{eq:elbo} over $q$.
paper.typ Typst
#set math.equation(numbering: "(1)")

= Variational bound <sec:bound>
For any $q(z divides x)$, the evidence is bounded below:

$
log p(x) gt.eq bb(E)_q[log p(x divides z)]-D_("KL") (q(z divides x) thin||thin p(z))
$ <eq:elbo>
We maximize Eq. (#ref(<eq:elbo>, supplement: none)) over $q$.
Real output of docmux 0.6.0. The macro is expanded, the labels become Typst labels, and the result compiles.

What you can do with it

Move a LaTeX paper to Typst

Your own macros are expanded, references and labels carry over, and citations are resolved from the .bbl file that arXiv ships with the sources.

Send a paper to someone who uses Word

Equations become native Word equations that can be edited, not images or LaTeX text. Cross-references jump to their target.

Convert inside your web app

Install the npm package and convert in the browser or in Node. No server to run, and no document leaves the user's machine.

Script it from the terminal or from Rust

Convert files with the docmux command, or use each reader and writer as its own Rust crate.

Formats

Every format is a reader and a writer around one shared document tree, so any input converts to any output.

Each reader, writer and transform is a separate Rust crate, so the WebAssembly build only carries what it uses.

Reader Document tree Transforms Writer
FormatReadWrite
LaTeX✓✓
Typst✓✓
Markdown (CommonMark + GFM)✓✓
Word (.docx)✓✓
HTML✓✓
MyST Markdown✓✓
Plain text–✓

Tested on real papers

Unit tests pass long before real documents do. So docmux is also checked against the LaTeX sources of eight well-known arXiv papers, and every failure they find becomes a small test in the crate that owns it.

  • VAE
  • Adam
  • ResNet
  • Transformer
  • BERT
  • GPT-3
  • DDPM
  • LoRA
Typst output that compiles
8 of 8
Equations written as native Word math
1,870
Raw LaTeX commands left in the output
0

Install

JavaScript

browser, Node
$ npm install @docmux/wasm

import { convert } from "@docmux/wasm";

const { output, error } = await convert(
  latex, "latex", "typst",
);

Command line

cargo
$ cargo install docmux-cli

$ docmux paper.tex -t typst -o paper.typ
$ docmux paper.tex -o paper.docx
$ docmux report.docx -o report.md

Rust

crates.io
$ cargo add docmux-core
$ cargo add docmux-reader-latex
$ cargo add docmux-writer-typst

let doc = LatexReader::new().read(src)?;
let opts = WriteOptions::default();
let typ = TypstWriter::new()
    .write(&doc, &opts)?;

Full API and options in the README.

What it is not

docmux covers a part of what pandoc does. pandoc handles many more formats and edge cases, and if it already works for you, there is no reason to switch. docmux is for when you need conversion inside a web app, under the MIT license, or with a focus on LaTeX, Typst and math in Word.

It is young, and real documents still find gaps. If one of yours breaks it, an issue with the file or a piece of it helps a lot.

Try it with your own document

The playground opens with a paper already converted. Drop in a .tex, .md, .typ or .docx file.

Open the playground