Skip to content
Markdown to PDF

Pandoc Markdown to PDF: Commands, Engines and Fixes

Convert Markdown to PDF with Pandoc — the basic command, options for margins, fonts and a table of contents, PDF engines without LaTeX, and common error fixes.

Updated · 6 min read

Pandoc is the standard command-line tool for converting documents, and Markdown to PDF is one of its most common jobs. The command is short; the part that trips people up is that Pandoc doesn’t write PDFs itself — it hands the work to a separate PDF engine that you have to install.

The basic command

pandoc notes.md -o notes.pdf

Pandoc works out the formats from the file extensions. By default it converts your Markdown to LaTeX and runs pdflatex to produce the PDF, so you need a LaTeX distribution: TeX Live on Linux, MacTeX on macOS, MiKTeX on Windows, or the much smaller TinyTeX on any of them.

Options worth knowing

pandoc notes.md -o notes.pdf \
  --toc --toc-depth=2 \
  --number-sections \
  -V geometry:margin=2cm \
  -V papersize=a4 \
  -V fontsize=12pt \
  -V colorlinks=true
Option What it does
--toc Adds a table of contents (--toc-depth sets how many heading levels; the default is 3)
--number-sections or -N Numbers the headings
-V geometry:margin=2cm Sets the page margins
-V papersize=a4 Paper size, e.g. a4 or letter
-V fontsize=12pt Body text size (10pt, 11pt or 12pt in the standard document classes)
-V colorlinks=true Colours links instead of boxing them
-f gfm Reads the file as GitHub Flavored Markdown

The title, author and date come from a metadata block at the top of the Markdown file:

---
title: Project report
author: Jane Doe
date: 15 November 2026
---

Variables can live there too (geometry: margin=2cm, fontsize: 12pt), which keeps the command short.

Choosing a PDF engine

--pdf-engine tells Pandoc which program builds the PDF:

Engine Needs Use it when
pdflatex (default) LaTeX Plain English text and math
xelatex or lualatex LaTeX Accents, non-Latin scripts, emoji or your own system fonts
typst Typst You want fast builds without a LaTeX install
weasyprint, wkhtmltopdf The tool itself You’d rather style the PDF with CSS

To use a font installed on your computer, switch to xelatex and name it:

pandoc notes.md -o notes.pdf --pdf-engine=xelatex -V mainfont="Georgia"

With an HTML-based engine, the output is styled by a stylesheet rather than LaTeX variables:

pandoc notes.md -o notes.pdf --pdf-engine=weasyprint --css=style.css

Fixing common errors

“pdflatex not found. Please select a different –pdf-engine or install pdflatex” — no LaTeX is installed. Install TinyTeX (or another distribution), or choose an engine you do have, such as --pdf-engine=typst.

“Unicode character … not set up for use with LaTeX” — pdflatex can’t handle a character in your file. Add --pdf-engine=xelatex.

A list comes out as one run-on paragraph — Pandoc’s own Markdown wants a blank line before a list, while GitHub doesn’t. Add the blank line, or read the file as GitHub Flavored Markdown with -f gfm.

Mermaid diagrams appear as code — Pandoc doesn’t draw diagrams. You need a filter that renders them to images first, which means installing more tooling.

You need a page break — \newpage on its own line works for LaTeX-based PDFs. Other formats need a different approach; see page breaks in Markdown.

Can Pandoc convert PDF to Markdown?

No. Pandoc can write PDFs but it can’t read them — PDF isn’t one of its input formats. Going from PDF back to Markdown needs a different kind of tool that extracts text and structure from the page.

When Pandoc is more than you need

Pandoc is the right choice for automated builds, academic papers with citations, and documents that must also come out as Word or EPUB. For a single document, installing a multi-gigabyte LaTeX distribution to get one PDF is a lot of setup. The online Markdown to PDF converter gives you page numbers, a table of contents, math, Mermaid diagrams and themes in the browser, with nothing to install. If you’d rather stay in your editor, see Markdown to PDF in VS Code; to script it, see Markdown to PDF in Python.

Try it on your own document

Free, private and right in your browser — no signup.

Open the editor