LaTeX Formula

Plugins Info

Docs stores the LaTeX formula source as editable content in the document model and renders 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 hold a commercial license for Univer, refer to Using License in Client for the configuration.

Mobile support

Set up the mobile editor first. In the plugin-mode setup described on this page, replace the desktop registrations below with the mobile exports from the same packages, and complete the replacement before opening a document. Keep the model plugins, styles, locales, and Facade imports unchanged, and do not register both variants.

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

Facade API

Import the facade entry before calling any LaTeX API:

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}',})

A formula can also be retrieved by range id or by its offset in the document's data stream:

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.