pandoc技术文档

简约无双

安装

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
# 批量转换当前目录下所有docx文件
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 markdown --template "../../dist/eisvogel.latex" --syntax-highlighting idiomatic --pdf-engine "xelatex" -V CJKmainfont="SimSun"

循环转换命令(windows):

1
2
3
4
5
6
7
8
9
10
11
12
13
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 `
--template "./resources/latex/eisvogel.latex" `
--syntax-highlighting idiomatic `
--pdf-engine "xelatex" `
-V CJKmainfont="SimSun"
}

示例markdown:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
---
title: "标题"
author: [你的名字]
date: "2026-09-12"
subject: "Markdown"
keywords: [关键词, markdown]
subtitle: "副标题"
titlepage: true,
titlepage-rule-color: "360049"
titlepage-background: "绝对路径"
page-background: "绝对路径"
---

## 二级标题

正文
  • 标题: pandoc技术文档
  • 作者: 简约无双
  • 创建于 : 2026-05-09 00:00:00
  • 更新于 : 2026-09-12 23:34:42
  • 链接: https://blog.jianyuewushuang.top/2026/05/09/pandoc技术文档/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论
目录
pandoc技术文档