Pandoc

You can generate a PDF from a CommonMark Markdown with extensions using Pandoc in one line: pandoc input.md -o output.pdf -pdf-engine=xelatex.

Pandoc doesn’t produce PDFs directly, it converts Markdown → LaTeX → PDF. You need LaTeX installed (e.g., TeX Live, MiKTeX, or MacTeX) and a PDF engine: • pdflatex – default, but limited with fonts/unicode • xelatex – best for modern fonts (recommended) • lualatex – advanced, supports OpenType • wkhtmltopdf or weasyprint – use if you want HTML → PDF instead of LaTeX

Pandoc can also produce PDF output via Groff ms, or HTML.

Add metadata (title, author, date)

You should include these in your Markdown file:

---
title: My Document
author: John Doe
date: 2025-11-10
---```
You can also hardcode it at the CLI:

pandoc input.md -o output.pdf
–metadata title=“My Document”
–metadata author=“John Doe”
–metadata date="$(date +%Y-%m-%d)"

### useful options
--toc                     # include a table of contents
--number-sections         # number your headers
--highlight-style tango   # syntax highlighting style for code blocks
--variable mainfont="Helvetica"  # change the main font

Example:

pandoc input.md -o output.pdf
–pdf-engine=xelatex
–toc –number-sections
–highlight-style=tango
-V mainfont=“Helvetica”


## Add a custom style (template or CSS)

If you use LaTeX:`pandoc input.md -o output.pdf --pdf-engine=xelatex --template=mytemplate.tex`

If you prefer an HTML-based approach (for better control with CSS):`pandoc input.md -o output.pdf --pdf-engine=wkhtmltopdf -c style.css`

## Installation

macOS: `brew install pandoc mactex`
Debian: `sudo apt install pandoc texlive texlive-xetex`
Windows: Install [Pandoc](https://github.com/jgm/pandoc/releases/) and MiKTeX