Pandoc Cheatsheet - Document Conversion Command Reference

All essential Pandoc commands organized by use case, with 38+ entries you can copy and run directly. Find the right command fast when you need it.

Dev Tools·38 commands·Last updated 2026-07-21
Back to Dev Tools

Basic Conversion 8

pandoc input.md -o output.html
Markdown 转 HTML
pandoc input.md -o output.pdf
Markdown 转 PDF(需 LaTeX)
pandoc input.md -o output.docx
Markdown 转 Word
pandoc input.html -o output.md
HTML 转 Markdown
pandoc input.docx -o output.md
Word 转 Markdown
pandoc input.md -o output.epub
Markdown 转电子书
pandoc -f markdown -t html5 input.md -o output.html
显式指定InputOutput格式
pandoc input.md -o output.org
Markdown 转 Org-mode

PDF Advanced Options 5

pandoc input.md -o output.pdf --pdf-engine=xelatex
使用 xelatex 引擎(supports中文)
pandoc input.md -o output.pdf -V mainfont="Noto Sans CJK SC"
指定中文字体
pandoc input.md -o output.pdf --toc
生成Directory
pandoc input.md -o output.pdf --toc --toc-depth=3
Directory层级 3 级
pandoc input.md -o output.pdf -V geometry:margin=1in
Set页边距

Templates & Styles 5

pandoc -s input.md -o output.html
生成独立 HTML(含 head)
pandoc input.md --template=mytemplate.html -o output.html
使用自定义template
pandoc input.md --css=style.css --self-contained -o output.html
内嵌 CSS 生成单File
pandoc input.md -H header.html -o output.html
在 head 中Insert自定义内容
pandoc -o template.html --print-default-template html5
Output默认template

Metadata & Slides 5

pandoc input.md -V title="标题" -V author="作者" -o output.pdf
Set元数据
pandoc input.md -t beamer -o output.pdf
Markdown 转 Beamer 幻灯片
pandoc input.md -t slidy -o output.html
转 Slidy HTML 幻灯片
pandoc input.md -t revealjs -o output.html
转 reveal.js 幻灯片
pandoc input.md -f markdown -t plain
转纯文本(去格式)

Citations & Math 6

pandoc input.md --citeproc -o output.pdf
启用引用文献处理
pandoc input.md --bibliography=refs.bib --citeproc -o output.pdf
指定 BibTeX 文献库
pandoc input.md --csl=ieee.csl -o output.pdf
指定引用格式(CSL 样式)
pandoc input.md --mathjax -o output.html
用 MathJax render数学公式
pandoc input.md --katex -o output.html
用 KaTeX render数学公式
pandoc --list-extensions markdown
List Markdown supports的扩展

Common Parameters 9

--highlight-style=tango
代码highlight主题
--number-sections
给标题加编号
--standalone / -s
生成完整文档(含头尾)
--metadata-file=meta.yaml
从 YAML Read元数据
--filter=pandoc-filter
使用自定义Filter器
-V key=value
传递variable给template
--wrap=auto
自动换行(auto/preserve/none)
--columns=80
Set换行列宽
--reference-doc=template.docx
用 Word 参考文档控制样式

💡 Tips

  • 中文 PDF 必须用 xelatex 引擎并指定中文字体,否则乱码。
  • Markdown 转 Word 后样式可能丢失,建议先转 HTML 再转 DOCX 保真度更高。
  • pandoc --list-output-formats 查看所有支持的输出格式。

Official References

Commands are compiled from the official docs below. Click to verify the latest usage.

Maintained by LaoHand

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

Found an error? Report it

Wrong command or description? Open an issue to help us fix it.

Found an error? Report it