LaTeX Formula

Plugins Info

The LaTeX formula feature lets Docs store editable formula source in the document model and render it in the browser editor.

Plugin Mode

Installation

Shell
pnpm add @univerjs-pro/docs-latex @univerjs-pro/docs-latex-ui

Usage

TypeScript
import { UniverDocsLatexPlugin } from '@univerjs-pro/docs-latex'import { UniverDocsLatexUIPlugin } from '@univerjs-pro/docs-latex-ui'import DocsLatexUIEnUS from '@univerjs-pro/docs-latex-ui/locale/en-US'import { LocaleType, mergeLocales, Univer } from '@univerjs/core'import '@univerjs-pro/docs-latex-ui/lib/index.css'import '@univerjs-pro/docs-latex/facade'const univer = new Univer({  locale: LocaleType.EN_US,  locales: {    [LocaleType.EN_US]: mergeLocales(      DocsLatexUIEnUS,     ),  },})univer.registerPlugin(UniverDocsLatexPlugin)univer.registerPlugin(UniverDocsLatexUIPlugin)

If you have a commercial license for Univer, please refer to Using License in Client for configuration.

Mobile support

First configure the mobile editor. In this page’s plugin-mode setup, replace the desktop registrations below with their mobile exports from the same packages, before opening a document. Keep the model plugins, styles, locales and Facade imports; do not register both variants.

PackageDesktop registrationMobile registration
@univerjs-pro/docs-latex-uiUniverDocsLatexUIPluginUniverDocsLatexMobileUIPlugin

Facade API

Import the facade entry before calling LaTeX APIs:

TypeScript
import '@univerjs-pro/docs-latex/facade'

Insert a formula into the active document:

TypeScript
const doc = univerAPI.getActiveDocument()const formula = doc?.insertLatexFormula({  latex: 'E=mc^2',  index: 12,})

Read and update formulas:

TypeScript
const formulas = doc?.getLatexFormulas() ?? []const firstFormula = doc?.findLatexFormulaByText('mc')firstFormula?.update({  latex: '\\frac{a}{b}',})

You can also query by range id or by document data-stream offset:

TypeScript
const byId = doc?.getLatexFormula('formula-range-id')const atOffset = doc?.getLatexFormulaAt(42)console.log(byId?.describe(), atOffset?.getLatex())

How is this guide?

© 2026 DreamNum Co., Ltd.