Pandoc Cheatsheet - Document Conversion Command Reference

Copy-pasting a document between formats usually destroys the structure you worked for. Pandoc converts between Markdown, HTML, PDF, DOCX and EPUB by mapping to a document model, so headings, tables and citations survive. This reference covers basic interchange, Chinese-PDF fonts, templates/styles, slides, e-books and citations/math. Use it when your CMS, wiki or client insists on a format you don't author in. After reading you move content across formats with markup intact.

Dev Tools·38 commands·Last updated 2026-07-21
pandocmarkdownDocument Conversionpdf

Basic Conversion 8

pandoc input.md -o output.html
Markdown to HTML
pandoc input.md -o output.pdf
Markdown to PDF (needs LaTeX)
pandoc input.md -o output.docx
Markdown to Word
pandoc input.html -o output.md
HTML to Markdown
pandoc input.docx -o output.md
Word to Markdown
pandoc input.md -o output.epub
Markdown to EPUB
pandoc -f markdown -t html5 input.md -o output.html
Explicitly set input/output formats
pandoc input.md -o output.org
Markdown to Org-mode

PDF Advanced Options 5

pandoc input.md -o output.pdf --pdf-engine=xelatex
Use xelatex engine (Chinese support)
pandoc input.md -o output.pdf -V mainfont="Noto Sans CJK SC"
Specify a Chinese font
pandoc input.md -o output.pdf --toc
Generate a table of contents
pandoc input.md -o output.pdf --toc --toc-depth=3
TOC depth of 3 levels
pandoc input.md -o output.pdf -V geometry:margin=1in
Set page margins

Templates & Styles 5

pandoc -s input.md -o output.html
Produce standalone HTML (with head)
pandoc input.md --template=mytemplate.html -o output.html
Use a custom template
pandoc input.md --css=style.css --self-contained -o output.html
Inline CSS into a single file
pandoc input.md -H header.html -o output.html
Inject custom content into head
pandoc -o template.html --print-default-template html5
Print the default template

Metadata & Slides 5

pandoc input.md -V title="Title" -V author="Author" -o output.pdf
Set metadata
pandoc input.md -t beamer -o output.pdf
Markdown to Beamer slides
pandoc input.md -t slidy -o output.html
To Slidy HTML slides
pandoc input.md -t revealjs -o output.html
To reveal.js slides
pandoc input.md -f markdown -t plain
To plain text (strip formatting)

Citations & Math 6

pandoc input.md --citeproc -o output.pdf
Enable citation processing
pandoc input.md --bibliography=refs.bib --citeproc -o output.pdf
Specify a BibTeX library
pandoc input.md --csl=ieee.csl -o output.pdf
Specify citation style (CSL)
pandoc input.md --mathjax -o output.html
Render math with MathJax
pandoc input.md --katex -o output.html
Render math with KaTeX
pandoc --list-extensions markdown
List Markdown extensions supported

Common Flags 9

--highlight-style=tango
Code highlighting theme
--number-sections
Number section headings
--standalone / -s
Produce a complete document (with head/foot)
--metadata-file=meta.yaml
Read metadata from YAML
--filter=pandoc-filter
Use a custom filter
-V key=value
Pass a variable to the template
--wrap=auto
Auto-wrap lines (auto/preserve/none)
--columns=80
Set wrap column width
--reference-doc=template.docx
Use a Word reference doc for styling

Tips

  • Chinese PDFs must use the xelatex engine and a Chinese font, or text is garbled.
  • Markdown to Word may lose styles; convert to HTML first, then DOCX for better fidelity.
  • Run pandoc --list-output-formats to see all supported output formats.

Official References

Each command links to its official documentation below, so you can verify the latest usage and read deeper.

Maintained by LaoHand

Publicly updated on Jul 21, 2026, continuously proofread against official docs.

Contact Us

Wrong command or description? Send us corrections, business inquiries or product feedback by email.

Contact Us