安装
windows
1
| winget install JohnMacFarlane.Pandoc
|
linux
1 2
| sudo apt update sudo apt install pandoc
|
验证:pandoc --version
基础转换
1 2 3 4 5 6
| pandoc input.docx -o output.md
pandoc input.docx --extract-media=./images -o output.md
for file in *.docx; do pandoc "$file" --extract-media="./${file%.docx}_images" -o "${file%.docx}.md"; done
|
高级转换
一篇教程
从模板库中clone一个模板仓库:
1
| git clone https://github.com/Wandmalfarbe/pandoc-latex-template.git
|
按照README写好markdown文件后执行转换命令:
1
| pandoc "document.md" -o "document.pdf" --from gfm+alerts --template "../../dist/eisvogel.latex" --syntax-highlighting idiomatic --pdf-engine "xelatex" -V CJKmainfont="SimSun" --lua-filter "./resources/alerts.lua"
|
循环转换命令(windows):
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| chcp 65001 | Out-Null Set-Location $PSScriptRoot Get-ChildItem -Path "./src" -Filter "*.md" | ForEach-Object { $inputFile = $_.FullName $outputFile = Join-Path "./build" ($_.BaseName + ".pdf") pandoc $inputFile ` -o $outputFile ` --from markdown+alerts ` --template "./resources/latex/eisvogel.latex" ` --syntax-highlighting idiomatic ` --pdf-engine "xelatex" ` -V CJKmainfont="SimSun"` --lua-filter "./resources/alerts.lua" }
|
示例markdown:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| --- title: "标题" author: [你的名字] date: "2026-09-12" subject: "Markdown" keywords: [关键词, markdown] subtitle: "副标题" titlepage: true, titlepage-rule-color: "360049" titlepage-background: "C:/Users/jianyuewushuang/document/学习/学习科目/大二上/概率论/笔记/resources/background.pdf" page-background: "C:/Users/jianyuewushuang/document/学习/学习科目/大二上/概率论/笔记/resources/background.pdf" colorlinks: true toc: true toc-own-page: true ---
## 二级标题
正文
- 无序列表 - 无序列表
1. 有序列表 2. 有序列表
> [!CAUTION] > 引用
|