Converting Mathpix Markdown (MMD) with Mathpix Python SDK
The Mathpix Python SDK provides functionality to convert Mathpix Markdown (MMD) into other formats, such as PDF, DOCX, and standard Markdown.
Code Example
from mpxpy.mathpix_client import MathpixClient
client = MathpixClient(
app_id="your-app-id",
app_key="your-app-key"
)
# Define the Mathpix Markdown input with headers, math, and a table
mmd_input = """
## Part I
## Linear Regression
To make our housing example more interesting, let's consider a slightly richer dataset in which we also know the number of bedrooms in each house:
| Living area $\\left(\\text{feet}^{2}\\right)$ | \\#bedrooms | Price (1000\\$s) |
|:---:|:---:|:---:|
| 2104 | 3 | 400 |
| 1600 | 3 | 330 |
| 2400 | 3 | 369 |
| 1416 | 2 | 232 |
| 3000 | 4 | 540 |
| $\\vdots$ | $\\vdots$ | $\\vdots$ |
To perform supervised learning, we must decide how we're going to represent functions/hypotheses $h$ in a computer. As an initial choice, let's say we decide to approximate $y$ as a linear function of $x$:
$$
h_{\\theta}(x) = \\theta_{0} + \\theta_{1} x_{1} + \\theta_{2} x_{2}
$$
In the case where we have only one training example $(x, y)$, so that we can neglect the sum in the definition of $J$, we have:
$$
\\begin{aligned}
\\frac{\\partial}{\\partial \\theta_j} J(\\theta)
&= \\frac{\\partial}{\\partial \\theta_j} \\frac{1}{2} \\left(h_\\theta(x) - y\\right)^2 \\\\
&= \\left(h_\\theta(x) - y\\right) \\cdot \\frac{\\partial}{\\partial \\theta_j} \\left(h_\\theta(x) - y\\right)
\\end{aligned}
$$
"""
# Convert MMD to PDF (you can also use "docx", "html", or "md")
conversion = client.conversion_new(
mmd=mmd_input,
conversion_format={"pdf": True}
)
# Wait for the conversion to complete
conversion.wait_until_complete(timeout=30)
# Download the output to a local folder
conversion.download_output_to_local_path("pdf", path="./output")
- You can specify multiple output formats such as
pdf
,docx
, ormd
. - The
formats
parameter is used to request the desired output type.
Rendered Output Example: From MMD to PDF

This view shows the final PDF output generated from Mathpix Markdown input. It demonstrates how headers, LaTeX equations, and tables are rendered using the Mathpix SDK.