# LaTeX to MathML

Convert a LaTeX formula to MathML markup with KaTeX 0.19.1. The result is one math element with presentation MathML and your original LaTeX kept as an annotation, in display or inline mode, ready to paste into HTML, EPUB or XML documents. MathML renders natively in current Chrome, Edge, Firefox and Safari and is read aloud by screen readers, so your formulas stay accessible without any JavaScript.

## Frequently asked questions

### What does the output look like?

You get a single math element in the MathML namespace with a semantics wrapper. Inside it is presentation MathML built from elements such as mi, mn, mo, mfrac, msup and mtable, followed by an annotation with the encoding application/x-tex that holds your original LaTeX. Display mode adds display="block" to the math element.

### Where can I use the MathML?

Paste it straight into an HTML5 page, an EPUB 3 book, XHTML or an XML format such as JATS or DocBook. Many equation editors and office suites can also import MathML, which makes it a practical exchange format between tools that do not read LaTeX.

### Do browsers display MathML?

Yes. Chrome and Edge from version 109, Firefox and Safari render MathML natively, without scripts or stylesheets. Browsers draw it with their own math fonts, so it looks slightly different from KaTeX's HTML rendering, but the structure and spacing rules are the same.

### What is the difference between display and inline mode?

Display mode marks the formula with display="block", so it is set as a standalone equation with full-size fractions and limits above and below large operators. Inline mode leaves the attribute out, and the formula is set in the compact style meant for running text.

### Is my original LaTeX kept?

Yes. KaTeX stores the source in an annotation element inside the semantics wrapper. Browsers do not display it, but copy tools and other converters can use it to recover the exact LaTeX. Remove the annotation element if you do not want the source in your document.

### Which LaTeX commands are supported?

Everything KaTeX 0.19.1 supports, including fractions, roots, matrices, environments such as aligned, cases and array, accents, arrows, font commands like \mathbb and \mathcal, \text and \tag. Macros you define with \def or \newcommand inside the formula work too. Full documents, \usepackage and the mhchem \ce commands are not available.

### What happens when the formula has an error?

No MathML is returned. The tool reports the problem and the character where it happens, counted from 1, for example an unknown command, unbalanced braces, a double superscript or a command missing its argument.

### Are there any limits?

A formula can be up to 10,000 characters long, macros may expand at most 1,000 times, and sizes given to commands such as \rule and \kern are capped at 100em. Commands that link or load outside content, such as \href, \url and \includegraphics, are disabled and come out as unsupported text.

### Is MathML good for accessibility?

Yes. Screen readers such as VoiceOver, NVDA and JAWS can read MathML and let readers move through a formula piece by piece, which an image cannot offer. Keeping math as MathML instead of pictures is one of the simplest ways to make technical content accessible.

### How does this differ from KaTeX's normal output?

On a web page KaTeX normally outputs styled HTML for display plus hidden MathML for screen readers. This tool returns only the MathML part, exactly as KaTeX generates it, without the wrapping span, stylesheet or fonts, so it works anywhere MathML is understood.

Your ad here?

[Email us](mailto:hi@dennn.is?subject=Advertising%20on%20OneClick%20Pro)

[Ad The agent-ready plugin suite for WordPress.](https://sleekwp.com/?ref=oneclickpro)
