Markdown, LaTeX and rich output
Turn a notebook into a readable document: headings, tables and maths in Markdown cells, plus images, HTML and audio objects from IPython.display.
Markdown cells
A Markdown cell is rendered, not executed. Double-click to edit, Shift+Enter to render. Headings build the notebook outline shown in the table of contents panel.
| You type | You get |
|---|---|
# Title | Heading level 1, appears in the outline |
**bold** / *italic* | Emphasis |
`code` | Inline code |
- item | Bullet list |
| a | b | | Table with a header separator row |
> note | Block quote |
 | Image, path relative to the notebook |
## Method
We measured throughput over **three** runs.
| Run | Tokens/s |
|-----|----------|
| 1 | 41.2 |
| 2 | 43.0 |
Maths with LaTeX
Inline maths uses single dollars; display maths uses double dollars on their own line. Both are rendered by MathJax in JupyterLab.
The mean squared error is $\frac{1}{n}\sum_{i=1}^{n}(y_i - \hat{y}_i)^2$.
$$
\hat{\beta} = (X^{\mathsf{T}}X)^{-1}X^{\mathsf{T}}y
$$- Use raw LaTeX commands (
\frac,\sum,\alpha), not Unicode symbols. - Underscores inside maths are safe; underscores in plain Markdown mean italics.
- If a formula renders as red text, an unmatched brace or backslash is the usual cause.
Rich output objects
from IPython.display import display, Markdown, HTML, Image, Audio, Latex, JSON
display(Markdown("**Bold** text built at runtime"))
display(HTML("<table><tr><td>a</td><td>b</td></tr></table>"))
display(Image(filename="img/plot.png", width=320))
display(Latex(r"\int_0^1 x^2\,dx = \tfrac{1}{3}"))
display(JSON({"rows": 3, "ok": True}))These objects render inside the output area and are what makes a notebook report-like. The last expression in a cell is displayed automatically; display() lets you emit several outputs from one cell.
⚠️
Values printed with
print() are plain text and lose structure. Prefer returning a DataFrame or using display() so the output survives as a table rather than a wall of characters.FAQ
Why does my LaTeX work locally but break on GitHub?
Rendering backends differ. The notebook file stores the source, and each viewer renders it with its own maths library and Markdown dialect. Keep formulas standard, avoid custom macros, and check the rendered HTML export before sharing.
How do I include an image so it survives export?
Prefer a relative file path next to the notebook. For a truly self-contained file, paste the image into a Markdown cell directly, which stores the bitmap in the notebook JSON.
Related
Notebook fundamentals Notebooks vs scripts: jupytext, nbconvert and papermill
Last refreshed 2026-09-18.