Overview
The MathBlock plugin provides standalone, display-mode math equations rendered with KaTeX. Unlike MathInline, which appears inline within text, MathBlock creates a dedicated block for larger equations that are centered and rendered in display mode. Both plugins are part of the@yoopta/math package, following the same pattern as Code / CodeGroup from @yoopta/code.
Installation
Basic Usage
Pass the plugin tocreateYooptaEditor (wrapped with withMath).
Features
- Display-mode equations rendered with KaTeX (centered, larger font)
- Standalone block — not inline within text
- Click to edit, with live KaTeX preview
- Copy LaTeX source to clipboard
- HTML, Markdown, and email serialization
- Dark mode support
Using with Themes
The@yoopta/themes-shadcn package includes a styled MathBlock component with a card-based edit UI.
- Preview mode — centered display-mode rendering with hover overlay (copy + edit buttons)
- Edit mode — larger textarea with live preview, save/cancel/delete actions
Element Props
| Prop | Type | Description |
|---|---|---|
latex | string | The LaTeX expression string |
nodeType | string | Always 'void' for this plugin |
Commands
Import commands:import { MathBlockCommands } from '@yoopta/math'
buildMathBlockElement
Creates a math block element structure without inserting it.
updateMathBlock
Updates the LaTeX expression of an existing math block.
getMathBlockElement
Finds the math-block element in a given block.
openEditor / closeEditor
Controls the edit state (requires withMath extension). Shared with MathInline.
Editor Extension
MathBlock shares the samewithMath extension as MathInline. See the MathInline docs for details.
Parsers
HTML
Serializes to<div data-math-block data-latex="..."> with KaTeX-rendered content inside (display mode).
Deserializes from <div data-math-block> elements, reading the data-latex attribute.
Markdown
Serializes to block math syntax:LaTeX Examples
Common display-mode expressions:| Expression | LaTeX |
|---|---|
| Integral | \int_0^\infty e^{-x} dx = 1 |
| Summation | \sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6} |
| Matrix | \begin{pmatrix} a & b \\ c & d \end{pmatrix} |
| Aligned equations | \begin{aligned} x &= a + b \\ y &= c + d \end{aligned} |
| Limit | \lim_{x \to \infty} \frac{1}{x} = 0 |
| Binomial | \binom{n}{k} = \frac{n!}{k!(n-k)!} |
Related Plugins
MathInline
Inline math expressions within text
Code
Code blocks (another void block plugin)

