Pandoc Cheat Sheet

The universal document converter

Basic Syntax

The basic Pandoc command structure follows this pattern:

pandoc [options] [input-file]... -o output-file
Convert Markdown to HTML
pandoc -o output.html input.md
Converts a Markdown file to HTML
Convert Markdown to PDF
pandoc -o output.pdf input.md
Requires LaTeX to be installed
Convert Markdown to DOCX
pandoc -o output.docx input.md
Creates a Microsoft Word document
Convert HTML to Markdown
pandoc -o output.md input.html
Converts HTML to Markdown format
Multiple Input Files
pandoc -o output.pdf file1.md file2.md file3.md
Combines multiple input files into one output
Specify Input Format
pandoc -f markdown -o output.html input.txt
-f or --from specifies input format
Specify Output Format
pandoc -t html -o output.html input.md
-t or --to specifies output format
Read from Standard Input
echo "# Hello" | pandoc -f markdown -t html
Output is sent to standard output

Common Options

Standalone Document
pandoc -s -o output.html input.md
-s creates a full document with header and footer
Table of Contents
pandoc --toc -o output.html input.md
--toc generates a table of contents
Set TOC Depth
pandoc --toc --toc-depth=2 -o output.html input.md
Controls how many heading levels appear in TOC
CSS Styling
pandoc -c style.css -o output.html input.md
Apply custom CSS styling to HTML output
Syntax Highlighting
pandoc --highlight-style=zenburn -o output.html input.md
Available styles: pygments, kate, monochrome, espresso, zenburn, haddock, tango
Number Sections
pandoc --number-sections -o output.html input.md
Adds section numbers to headings
Template Variables
pandoc -V title="My Document" -o output.pdf input.md
Sets template variables for output
Bibliography
pandoc --bibliography=refs.bib -o output.html input.md
Processes citations and adds bibliography

Input Formats

Pandoc can read from these formats:

Markdown Variants
markdowncommonmarkgfmmarkdown_mmd
Various flavors of Markdown, including GitHub-Flavored Markdown (gfm)
Document Formats
docxodtepubhtmllatex
Common document formats
Other Markup
rsttextileorgmediawikidokuwiki
Various markup languages
Academic/Publishing
jatstexbiblatexbibtex
Formats used in academic publishing

Output Formats

Pandoc can write to these formats:

Document Formats
docxodtpdfepubhtml
Common document formats
Markdown Variants
markdowncommonmarkgfmmarkdown_mmd
Various flavors of Markdown
Presentations
pptxbeamerrevealjss5slideousslidy
Presentation formats
Other Markup
rsttextileorgmediawikidokuwiki
Various markup languages
Academic/Publishing
jatslatexcontexttexinfo
Formats used in academic publishing
Plain Text Formats
plainasciidocasciidoctorman
Plain text and documentation formats

PDF Output Options

PDF Margin
pandoc -V geometry:margin=1in -o output.pdf input.md
Sets document margins in inches
PDF Paper Size
pandoc -V geometry:a4paper -o output.pdf input.md
Sets paper size (a4paper, letterpaper, etc.)
PDF Font Size
pandoc -V fontsize=12pt -o output.pdf input.md
Sets document font size
PDF Font Family
pandoc -V mainfont="DejaVu Serif" -o output.pdf input.md
Sets main font family
Custom LaTeX Template
pandoc --template=template.tex -o output.pdf input.md
Use a custom LaTeX template for PDF output

Template Usage

Use Custom Template
pandoc --template=mytemplate.html -o output.html input.md
Uses a custom template for output
Print Default Template
pandoc -D html > mytemplate.html
Prints the default template for a format
Set Template Variables
pandoc -V author="John Doe" -V title="My Document" -o output.pdf input.md
Sets variables for use in templates
YAML Metadata Block
---
title: My Document
author: John Doe
date: 2025-03-02
---

# Content starts here
Include metadata within the Markdown document
Use Metadata File
pandoc --metadata-file=meta.yaml -o output.html input.md
Read metadata from external YAML file

Common Template Variables

Document Info
titleauthordatesubtitle
Basic document metadata
HTML Options
cssinclude-in-headerinclude-before-bodyinclude-after-body
Customizing HTML output
PDF/LaTeX Options
documentclassgeometrymainfontfontsizepapersize
LaTeX/PDF document styling
Language & Locale
langdirbabel-langlocale
Language and text direction settings

Using Filters

Filters allow transforming the document during conversion:

Apply Filter
pandoc --filter=pandoc-citeproc -o output.html input.md
Applies the pandoc-citeproc filter for citations
Multiple Filters
pandoc --filter=filter1.py --filter=filter2.py -o output.html input.md
Applies multiple filters in sequence
Lua Filter
pandoc --lua-filter=myfilter.lua -o output.html input.md
Applies a Lua filter

Common Pandoc Filters

pandoc-citeproc
pandoc --citeproc --bibliography=refs.bib -o output.html input.md
Processes citations using a bibliography file
pandoc-crossref
pandoc --filter=pandoc-crossref -o output.html input.md
Adds cross-reference support for figures, equations, tables
pandoc-include
pandoc --filter=pandoc-include -o output.html input.md
Allows including external files
pandoc-mermaid
pandoc --filter=pandoc-mermaid -o output.html input.md
Renders mermaid diagrams

Markdown Extensions

Enable Extensions
pandoc --from markdown+table_captions+pipe_tables -o output.html input.md
Enables specific Markdown extensions
Disable Extensions
pandoc --from markdown-raw_html-raw_tex -o output.html input.md
Disables specific Markdown extensions
Common Extensions
pipe_tablesfenced_code_blocksauto_identifiersdefinition_lists
footnotessmartyaml_metadata_blocktex_math_dollars
Frequently used Markdown extensions

Academic Writing

Academic Paper to PDF
pandoc --citeproc --bibliography=refs.bib --filter=pandoc-crossref --number-sections --toc -o paper.pdf paper.md
Create a PDF with citations, cross-references, section numbers and TOC
Conference Submission
pandoc -s --citeproc --bibliography=refs.bib --template=conference.latex -V documentclass=article -o submission.pdf paper.md
Create a paper using a specific LaTeX template
Book Creation
pandoc -s --toc --toc-depth=3 -o book.pdf title.txt chapters/*.md
Combine multiple chapter files into a book

Presentations & Slides

Beamer Presentation
pandoc -t beamer -o slides.pdf presentation.md
Convert Markdown to a Beamer PDF presentation
PowerPoint Slides
pandoc -o presentation.pptx presentation.md
Create PowerPoint slides from Markdown
Reveal.js Slides
pandoc -s -t revealjs -o slides.html presentation.md
Create web-based Reveal.js presentation
Themed Beamer
pandoc -t beamer -V theme:Warsaw -V colortheme:dolphin -o slides.pdf presentation.md
Beamer presentation with custom themes

Website & Documentation

Styled Website
pandoc -s --toc -c style.css -o website.html content.md
Create HTML with table of contents and custom CSS
Documentation Site
pandoc -s --toc --toc-depth=2 --number-sections -o docs.html docs/*.md
Combine documentation files with TOC and numbered sections
Wiki to Markdown
pandoc -f mediawiki -t markdown -o output.md input.wiki
Convert MediaWiki content to Markdown
Generate Man Page
pandoc -s -t man -o command.1 manpage.md
Create a Unix man page from Markdown