Overview
The MathInline plugin enables users to insert inline math expressions into any text block. Expressions are written in LaTeX and rendered using KaTeX. It works as aninlineVoid element, meaning it appears inline alongside regular text but is not directly editable — users edit the LaTeX source through a popover.
Part of the @yoopta/math package, which also includes the MathBlock plugin for standalone display-mode equations.
Installation
Basic Usage
Pass the plugin tocreateYooptaEditor (wrapped with withMath). Plugins and marks are passed to createYooptaEditor, not to <YooptaEditor>.
Features
- Inline math expressions rendered with KaTeX
- Works inside any text block (Paragraph, Headings, Callout, Lists, etc.)
- Live preview while editing LaTeX source
- Copy LaTeX source to clipboard
- Toolbar integration — select text and convert to math expression
- HTML, Markdown, and email serialization
- Dark mode support
Using with Themes
The@yoopta/themes-shadcn package includes a styled MathInline component with a HoverCard for preview and editing.
- Preview mode — rendered math, LaTeX source display, copy and edit buttons
- Edit mode — live preview, LaTeX textarea input, save/cancel/delete actions
Element Props
| Prop | Type | Description |
|---|---|---|
latex | string | The LaTeX expression string |
nodeType | string | Always 'inlineVoid' for this plugin |
Commands
Import commands:import { MathInlineCommands } from '@yoopta/math'
buildMathInlineElement
Creates a math inline element structure without inserting it.
insertMathInline
Inserts a math inline element at the current Slate selection.
updateMathInline
Updates the LaTeX expression of an existing math element.
deleteMathInline
Removes a math inline element by its ID.
findMathInlineElements
Finds all math inline elements in a block.
openEditor / closeEditor
Controls the edit popover state (requires withMath extension).
Editor Extension
ThewithMath function extends the editor with a math namespace for managing the edit popover state. This extension is shared between MathInline and MathBlock.
useMathState Hook
Subscribe to math state changes in React components (must be inside <YooptaEditor>).
Toolbar Integration
Add a math button to the floating toolbar that converts selected text into a math expression:Parsers
HTML
Serializes to<span data-math-inline data-latex="..."> with KaTeX-rendered content inside.
Deserializes from <span data-math-inline> elements, reading the data-latex attribute.
Markdown
Serializes to standard inline math syntax:$E = mc^2$
LaTeX Examples
Common expressions to use with the plugin:| Expression | LaTeX |
|---|---|
| Fraction | \frac{a}{b} |
| Square root | \sqrt{x} |
| Superscript | x^2 |
| Subscript | x_i |
| Summation | \sum_{i=1}^{n} x_i |
| Integral | \int_0^1 f(x) dx |
| Greek letters | \alpha, \beta, \gamma |
| Matrix | \begin{pmatrix} a & b \\ c & d \end{pmatrix} |
Related Plugins
MathBlock
Display-mode math equations as standalone blocks
Mention
@mentions (another inlineVoid element plugin)

