Export LibreOffice Math Equations as MathML Code

This guide covers the necessary settings and procedures to export formulas created in LibreOffice Math as standard MathML code. Whether you need to save standalone equation files, export a full LibreOffice Writer document containing formulas to the web, or extract raw MathML XML markup, LibreOffice provides built-in options to format and output your mathematical expressions correctly.

Exporting Standalone Equations as MathML (.mml)

To export an individual equation directly from LibreOffice Math:

  1. Open the formula in the LibreOffice Math editor.
  2. Click on File in the top menu and select Save As (or File > Export).
  3. In the file dialog, open the Save as type (or Filter) dropdown menu.
  4. Select **MathML 2.0 (*.mml)**.
  5. Choose your destination folder, name the file, and click Save.

The resulting .mml file contains pure MathML XML markup that can be opened in any text editor or imported into web pages.

HTML and XHTML Export Settings in LibreOffice Writer

When embedding equations within a LibreOffice Writer document and exporting to the web, configure your export settings to preserve formulas as MathML instead of raster images:

  1. Navigate to Tools > Options (on macOS: LibreOffice > Preferences).
  2. Expand the Load/Save section in the left sidebar and select HTML Compatibility.
  3. Under the Export section, ensure your settings favor modern web standards.
  4. To generate native MathML embedded in web output, use File > Export and select **XHTML (*.xhtml)** as the file format. The XHTML export filter automatically converts embedded LibreOffice Math objects into inline MathML markup (<math ...>...</math>).

Copying MathML via the Clipboard

If you need quick access to the raw MathML markup without saving a file:

  1. Save or export the formula as a .mml file using the standalone method above.
  2. Open the .mml file in a standard text editor (such as Notepad, TextEdit, or VS Code).
  3. Copy the XML code block starting with <math xmlns="http://www.w3.org/1998/Math/MathML"> and paste it directly into your target application or HTML source.