Guide
How to Convert a Jupyter Notebook to PDF
Exporting a Jupyter notebook to PDF should be one command — and sometimes it is. But the default path runs through LaTeX, which means a missing package or a stray character can turn a two-minute task into an afternoon of error messages. This guide covers the three reliable ways to get a PDF out of a .ipynb, from the LaTeX route to a no-LaTeX browser fallback.
Method 1 — nbconvert with LaTeX (the classic)
If you have a LaTeX distribution installed, nbconvert produces a beautifully typeset PDF:
jupyter nbconvert --to pdf notebook.ipynb
Or from inside the classic notebook UI: File → Download as → PDF via LaTeX (.pdf).
The catch is the dependency chain. This route needs Pandoc and a TeX installation (TeX Live, MiKTeX, or MacTeX), plus XeLaTeX. If any is missing you'll see errors like nbconvert failed: xelatex not found or complaints about a missing .sty package. Install a TeX distribution first, and the command starts working.
Method 2 — WebPDF (no LaTeX required)
If you'd rather skip TeX entirely, nbconvert can render through a headless Chromium instead:
pip install "nbconvert[webpdf]"
jupyter nbconvert --to webpdf --allow-chromium-download notebook.ipynb
This uses the browser's print engine, so you get clean output without a LaTeX install. It's the fastest fix when the LaTeX route is fighting you — the trade-off is a one-time Chromium download.
Method 3 — HTML, then print
Every Jupyter install can export HTML, and every browser can print HTML to PDF:
jupyter nbconvert --to html notebook.ipynb
Open the resulting .html file in your browser and press Ctrl/Cmd + P → Save as PDF. It's universally available and needs zero extra packages — you just get less control over margins and page breaks than the dedicated exporters.
Method 4 — the Markdown route (for the write-up, not the code output)
Sometimes you don't need the executed cells and plots — you need a clean document built from the notebook's Markdown cells (the narrative, headings, tables, and equations). Convert the notebook to Markdown, then to PDF:
jupyter nbconvert --to markdown notebook.ipynb
That gives you a .md file. Paste it into a browser converter like ConvertMDapp, preview it live, and click Export PDF. You get selectable text, clean typography, and a small file — ideal for a report or a shareable summary where the raw code cells would just be noise. It runs entirely in your browser, so nothing is uploaded.
This is also the most portable option: no LaTeX, no Chromium download, works on any machine including one where you can't install packages.
Which method fits?
| You want… | Use |
|---|---|
| Typeset, publication-quality output | Method 1 (LaTeX) |
| A PDF now, without installing TeX | Method 2 (WebPDF) |
| Zero extra packages | Method 3 (HTML → print) |
| A clean write-up from the Markdown cells | Method 4 (Markdown → convert) |
Fixing the common LaTeX errors
xelatex not found— install a TeX distribution (MacTeX, MiKTeX, or TeX Live) and reopen your terminal.- Missing
.stypackage — with MiKTeX, allow on-the-fly package installs; with TeX Live, runtlmgr install <package>. - A cell with a special character breaks the build — the LaTeX engine chokes on some Unicode. Switch to
--to webpdf, which doesn't care. - Emoji or non-Latin text vanishes — XeLaTeX needs a font that includes those glyphs; WebPDF or the Markdown route handles them out of the box.
FAQ
Why does jupyter nbconvert --to pdf fail?
Almost always because the LaTeX toolchain isn't fully installed. It needs Pandoc plus a TeX distribution with XeLaTeX. Install one, or switch to --to webpdf to avoid LaTeX altogether.
How do I convert a notebook to PDF without installing LaTeX?
Use jupyter nbconvert --to webpdf (renders via headless Chromium), or export to HTML and print to PDF from your browser. For just the write-up, convert to Markdown and use a browser converter.
Can I export only the Markdown cells to PDF?
Yes — run jupyter nbconvert --to markdown notebook.ipynb, then convert that .md file to PDF. For the fundamentals, see the guide to converting Markdown to PDF and the Pandoc walkthrough.