API Reference

FDocumentLatex

Facade object for a single LaTeX formula in a Univer document.

Access

Access through:

Example

TypeScript
const univerAPI = FUniver.newAPI(univer)const document = univerAPI.getActiveDocument()if (!document) throw new Error('No active document')const formula = document.getLatexFormulas()[0]if (!formula) throw new Error('No LaTeX formula')console.log(formula.getLatex())console.log(formula.getConfig())if (!formula.update({ latex: '\\frac{a}{b}' })) throw new Error('Cannot update LaTeX formula')

Setup

Register @univerjs-pro/docs-latex or a preset that includes it. In plugin mode, import @univerjs-pro/docs-latex/facade. Additional methods below require their listed plugin packages. See Facade setup.

@univerjs-pro/docs-latex

FDocumentLatex.describe

Returns an agent-friendly description of this formula.

TypeScript
describe(): IDocsLatexInfo | null

Returns

The formula id, range, source, and config, or null if it no longer exists.

Examples

TypeScript
const univerAPI = FUniver.newAPI(univer)const document = univerAPI.getActiveDocument()if (!document) throw new Error('No active document')const formula = document.getLatexFormulas()[0]if (!formula) throw new Error('No LaTeX formula')console.log(formula.describe())

Types: IDocsLatexInfo

Package: @univerjs-pro/docs-latex · Type definitions

FDocumentLatex.getConfig

Returns the normalized formula configuration.

TypeScript
getConfig(): IDocsLatexFormulaConfig

Returns

The formula source and visual properties.

Examples

TypeScript
const univerAPI = FUniver.newAPI(univer)const document = univerAPI.getActiveDocument()if (!document) throw new Error('No active document')const formula = document.getLatexFormulas()[0]if (!formula) throw new Error('No LaTeX formula')console.log(formula.getConfig().kind)

Types: IDocsLatexFormulaConfig

Package: @univerjs-pro/docs-latex · Type definitions

FDocumentLatex.getId

Returns the LaTeX formula range id.

TypeScript
getId(): string

Returns

The custom range id that identifies this formula.

Examples

TypeScript
const univerAPI = FUniver.newAPI(univer)const document = univerAPI.getActiveDocument()if (!document) throw new Error('No active document')const formula = document.getLatexFormulas()[0]if (!formula) throw new Error('No LaTeX formula')console.log(formula.getId())

Package: @univerjs-pro/docs-latex · Type definitions

FDocumentLatex.getLatex

Returns the editable LaTeX source for this formula.

TypeScript
getLatex(): string

Returns

The LaTeX source, or an empty string if the formula range is gone.

Examples

TypeScript
const univerAPI = FUniver.newAPI(univer)const document = univerAPI.getActiveDocument()if (!document) throw new Error('No active document')const formula = document.getLatexFormulas()[0]if (!formula) throw new Error('No LaTeX formula')console.log(formula.getLatex())

Package: @univerjs-pro/docs-latex · Type definitions

FDocumentLatex.getRange

Returns this formula's document data-stream range.

TypeScript
getRange(): IDocsLatexRange | null

Returns

The formula range, or null if it no longer exists.

Examples

TypeScript
const univerAPI = FUniver.newAPI(univer)const document = univerAPI.getActiveDocument()if (!document) throw new Error('No active document')const formula = document.getLatexFormulas()[0]if (!formula) throw new Error('No LaTeX formula')console.log(formula.getRange())

Types: IDocsLatexRange

Package: @univerjs-pro/docs-latex · Type definitions

FDocumentLatex.remove

Removes this formula and its source text from the document.

TypeScript
remove(): boolean

Returns

Whether the remove command succeeded.

Examples

TypeScript
const univerAPI = FUniver.newAPI(univer)const document = univerAPI.getActiveDocument()if (!document) throw new Error('No active document')const formula = document.getLatexFormulas()[0]if (!formula) throw new Error('No LaTeX formula')if (!formula.remove()) throw new Error('Failed to remove LaTeX formula')

Package: @univerjs-pro/docs-latex · Type definitions

FDocumentLatex.replaceWithText

Replaces this formula with plain text.

TypeScript
replaceWithText(text: string): boolean

Parameters

  • text — Required. Plain replacement text.

Returns

Whether the replace command succeeded.

Examples

TypeScript
const univerAPI = FUniver.newAPI(univer)const document = univerAPI.getActiveDocument()if (!document) throw new Error('No active document')const formula = document.getLatexFormulas()[0]if (!formula) throw new Error('No LaTeX formula')if (!formula.replaceWithText('F = ma')) throw new Error('Failed to replace LaTeX formula')

Package: @univerjs-pro/docs-latex · Type definitions

FDocumentLatex.update

Updates this formula's source and optional visual properties.

TypeScript
update(options: IDocsLatexUpdateFacadeOptions): boolean

Parameters

  • options — Required. The replacement LaTeX source and property patch.

Returns

Whether the update command succeeded.

Examples

TypeScript
const univerAPI = FUniver.newAPI(univer)const document = univerAPI.getActiveDocument()if (!document) throw new Error('No active document')const formula = document.getLatexFormulas()[0]if (!formula) throw new Error('No LaTeX formula')if (!formula.update({ latex: '\\frac{a}{b}' })) throw new Error('Cannot update LaTeX formula')

Types: IDocsLatexUpdateFacadeOptions

Package: @univerjs-pro/docs-latex · Type definitions

How is this guide?

© 2026 DreamNum Co., Ltd.