Want to add professional-quality math equations to your Jupyter notebooks? LaTeX math formatting lets you write clear, beautifully rendered formulas that enhance your data science and teaching notebooks.
- Use
$ ... $for inline math and$$ ... $$for display (block) math. - Supports most standard LaTeX math commands and symbols.
- Combine text and math seamlessly inside Markdown cells.
- Great for writing formulas, equations, and scientific notation.
Step 1: Open a Markdown Cell
Start by creating a new Markdown cell in your Jupyter Notebook. You can add a cell and switch its type to Markdown or press M in command mode.
Step 2: Write Inline Math Using Dollar Signs
For math expressions that appear inline with your text, wrap your LaTeX code inside single dollar signs $ ... $. For example:
The formula for the area of a circle is $A = \pi r^2$.
When you run the cell, the math will render like this:
The formula for the area of a circle is A = π r².
Step 3: Write Display (Block) Math Using Double Dollar Signs
For larger equations that you want to display on their own line and centered, use double dollar signs $$ ... $$. For example:
$$
E = mc^2
$$
This renders as a centered block equation:
E = mc²
Step 4: Use Common LaTeX Math Commands
You can use many standard LaTeX commands in your expressions, such as fractions, square roots, summations, and integrals. Here are a few examples:
- Fraction:
$\frac{a}{b}$renders as 𝑎⁄𝑏 - Square root:
$\sqrt{x}$renders as √𝑥 - Summation:
$$\sum_{i=1}^n i^2$$renders as a centered summation symbol - Integral:
$$\int_0^\infty e^{-x} dx$$renders as a centered integral
Step 5: Combine Text and Math Smoothly
You can mix normal text and math expressions easily within the same Markdown cell. Just wrap math parts in dollar signs and write the rest as usual:
The solution to $ax^2 + bx + c = 0$ is given by
$$
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
$$
Tips & Tricks
- Use backslashes
\to escape special characters in LaTeX. - For complex equations, test small parts first to avoid syntax errors.
- Combine with Markdown formatting (bold, italic) for clearer explanations.
Summary
| Syntax | Result |
|---|---|
$ ... $ | Inline math |
$$ ... $$ | Display (block) math |
Using LaTeX math in Jupyter Markdown lets you write clear, professional equations that improve readability and presentation. Whether you’re explaining a formula or presenting scientific results, this feature helps make your notebooks look polished and accessible.
Related Articles
- How to add checkboxes in Jupyter Notebook Markdown – Track your tasks visually inside notebooks
- How to change text color in Jupyter Notebook – Highlight important points for clarity
- How to change a cell to Markdown mode (2 Ways) – Convert a cell to Markdown mode and start styling text