Guide · Pandoc

Pandoc Markdown to PDF: commands and setup

Pandoc is a powerful command-line converter, but a PDF is not produced by Pandoc alone. This guide explains the command, the PDF engine requirement and the parts that usually need tuning.

Updated November 23, 2026 · Markdown2PDF by Hyperdyn

The basic Pandoc command

Once Pandoc and a PDF engine are installed, the shortest command is:

pandoc input.md -o output.pdf

Pandoc reads Markdown and writes a PDF through an intermediate format. With the default LaTeX route, a TeX distribution such as TeX Live, MiKTeX or MacTeX must be installed and available on your path. If it is missing, Pandoc can parse the Markdown but cannot finish the PDF.

Install Pandoc and a PDF engine

Install Pandoc from the official releases or your package manager, then install a PDF engine. For the default route, that means a LaTeX distribution. Check the tools are visible before debugging a document:

pandoc --version
pdflatex --version

If you prefer XeLaTeX or LuaLaTeX, install the corresponding engine and select it explicitly. The right choice depends on fonts, language support and the packages your template needs.

Useful options for a real document

A longer command can set the engine, margins, table of contents and syntax highlighting:

pandoc input.md \
  -o output.pdf \
  --pdf-engine=xelatex \
  --toc \
  -V geometry:margin=20mm \
  --highlight-style=tango
  • --pdf-engine selects the program that turns the intermediate document into a PDF.
  • --toc adds a table of contents when the output format supports it.
  • -V geometry:margin=20mm passes a template variable to the LaTeX template.
  • --highlight-style controls code highlighting for supported writers.

Templates, fonts and page breaks

Pandoc's default PDF look is functional, not branded. A custom template controls title pages, headers, fonts, spacing and page geometry. With LaTeX output, a raw \\newpage can force a break, but raw LaTeX is engine-specific and should not be mixed into Markdown that also needs to render on the web.

For CJK or other non-Latin scripts, select an engine and fonts that cover the characters. Missing glyphs usually show up as blank boxes or warnings, not a helpful error.

Images and resource paths

Relative image paths are resolved from the working directory or the resource path. If an image works in a Markdown preview but disappears from the PDF, check the path case and add the directory explicitly:

pandoc input.md -o output.pdf --resource-path=.:assets

Remote images may be fetched during conversion. In a restricted environment, download them first and keep the document self-contained.

When a browser converter is simpler

Pandoc is excellent for repeatable, scripted documents and for teams that already use LaTeX. It is less convenient when you want to paste Markdown, see paginated pages and adjust typography without installing a TeX distribution.

Markdown2PDF runs in the browser, previews the actual page breaks and exports a PDF after sign-in. It does not replace Pandoc for batch pipelines or LaTeX-heavy documents; it removes the local toolchain for a quick, visual document.

Frequently asked questions

Why does Pandoc fail to create a PDF?

The usual cause is a missing PDF engine. Pandoc can read Markdown without LaTeX, but the default PDF route needs a TeX installation. Install one and confirm pdflatex is on your PATH.

Can Pandoc convert Markdown to PDF without LaTeX?

Pandoc can use other PDF engines and intermediate formats, depending on the version and the writer. The exact options vary, so check the current Pandoc manual and the engine you plan to use.

Does Pandoc support GitHub-flavored Markdown?

Yes. Use the gfm reader when you need GitHub-flavored Markdown semantics. Pandoc’s own Markdown dialect supports more features, but it is not identical to GitHub’s renderer.