pandoc安装
-
访问pandoc tags,切换至想要安装的版本,本次安装3.6.4
-
下载windows版本
-
下载texlive镜像,将文件转换成pdf需要用到
点开后会进入最近的镜像网站
- 下载完成后解压iso文件,以管理员身份运行install-tl-windows.bat,后续默认安装即可
- 维护pandoc和texlive的环境变量
测试
- 编写test.md
# test
- 1
- 2
- 3
- 执行转换命令
pandoc test.md -o test.pdf
-
查看生成结果
-
适配中文
如果markdown文档中有中文,直接执行会有如下报错
pandoc test.md -o test.pdf
Error producing PDF.
! LaTeX Error: Unicode character 浣?pandoc: <stderr>: hPutChar: invalid argument (Invalid argument)
可以通过以下方式解决
#通过--pdf-engine指定xelatex引擎,通过CJKmainfont指定字体(此次用宋体)
pandoc test.md -o test.pdf --pdf-engine=xelatex -V CJKmainfont=SimSun