Skip to content

renderMath

Official

Render some LaTeX math using the MathJax engine. Returns an HTMLElement. Requires calling finishRenderMath when rendering is all done to flush the MathJax stylesheet.

Import:

import { renderMath } from 'obsidian';

Signature:

function renderMath(source: string, display: boolean): HTMLElement

Parameters:

Parameter Type Description
source string The LaTeX source code.
display boolean Whether to render the math in display mode.

Returns: HTMLElement — The rendered math element.

Example:

console.log(renderMath('\\frac{1}{2}', true));