Runnable examples

Explore 30 complete examples. Download a Word document or run its Python source locally.

All example source and assets (ZIP)

Download and extract the ZIP, then run the following commands from the folder containing examples/. The bundle includes helper modules and assets used by the examples.

Running all examples requires Python 3.6.2+ for LaTeX. Example 17 also uses docxtpl, included in the installation command below.

python -m pip install "mathml2docx[latex,markdown]" "docxtpl>=0.16,<1"
python -m examples.run_all

Outputs go to examples/output/. To run one example, use python -m examples.01_quickstart. The commands use the published PyPI package.

In an initialized uv or Poetry project, use the corresponding commands below instead. See installation for project setup. For a single example, replace examples.run_all with its module name.

uv add "mathml2docx[latex,markdown]" "docxtpl>=0.16,<1"
uv run python -m examples.run_all
poetry add "mathml2docx[latex,markdown]" "docxtpl>=0.16,<1"
poetry run python -m examples.run_all

Open an example to compare its HTML/MathML in the browser with the LibreOffice PDF output. Use the DOCX download to edit equations in Word. Fonts and document applications can change line wrapping and pagination.