Porting LaTeX from Jupyter to marimo
Jupyter uses MathJax. marimo uses KaTeX (faster, slightly narrower coverage, silent errors).
Use raw strings
LaTeX lives in Python strings in marimo, so use r"..." to preserve backslashes:
mo.md(r"$\frac{1}{2}$") # correct
mo.md("$\frac{1}{2}$") # wrong — \f is a form-feed characterJupyter (MathJax) → marimo (KaTeX)
| Category | Jupyter (MathJax) | marimo (KaTeX) |
|---|---|---|
| Text | \mbox, \bbox |
\text{} |
| Text style | \textsc, \textsl |
\text{} |
| Environments | \begin{eqnarray} |
\begin{align} |
\begin{multline} |
\begin{gather} |
|
| References | \label, \eqref, \ref |
\tag{} for manual numbering |
| Arrays | \cline, \multicolumn, \hfill, \vline |
not supported |
| Macros | \DeclareMathOperator |
\operatorname{} inline |
\newenvironment |
not supported | |
| Spacing | \mspace, \setlength, \strut, \rotatebox |
not supported |
| Conditionals | \if, \else, \fi, \ifx |
not supported |
These DO work in KaTeX (despite outdated claims): \newcommand, \def, \hbox, \hskip, \cal, \pmb, \begin{equation}, \begin{split}, \operatorname*.
Migration checklist
- Find-replace
\mbox{→\text{ - Use raw strings (
r"...") - Replace
\begin{eqnarray}→\begin{align} - Replace
\DeclareMathOperator→\operatorname{} - Remove
\label/\eqref→ use\tag{}if needed - Visually verify — KaTeX fails silently
References
- KaTeX Support Table — definitive command lookup
- KaTeX Unsupported Features