Docs
Equation

Equation

Enables the insertion and rendering of LaTeX equations in your editor.

Features

  • Allows you to insert inline LaTeX equations (e.g., $E=mc^2$) and block equations (e.g., $$\int_a^b f(x) dx$$) into your editor.
  • Renders both inline and block equations using KaTeX for high-quality mathematical typesetting.
  • Supports a wide range of LaTeX commands and symbols for complex mathematical expressions.

Installation

npm install @udecode/plate-math

Usage

// ...
import { InlineEquationPlugin, EquationPlugin } from '@udecode/plate-math';
 
const editor = usePlateEditor({
  id: 'equation-demo',
  override: {
    components: {
      ...otherComponents,
      [EquationPlugin.key]: EquationElement,
      [InlineEquationPlugin.key]: InlineEquationElement,
    },
  },
  plugins: [...commonPlugins, InlineEquationPlugin, EquationPlugin],
  value: equationValue,
});

Transforms

editor.tf.insert.equation

Inserts a empty block equation.

Parameters

Collapse all

    Options for the insert nodes transform.

editor.tf.insert.inlineEquation

Inserts an inline equation.

Parameters

Collapse all

    The LaTeX expression to insert. If not provided, an empty equation will be inserted.

    Options for the insert nodes transform.