Pandoc安装与使用总结

Pandoc安装与使用总结

1. Pandoc的安装

1.1. Pandoc在Win10下的安装

关于标记语言转换工具Pandoc在Windows10安装和使用: https://blog.csdn.net/xtjatswc/article/details/109572110

1.1.1. Pandoc安装方式

由于Pandoc本身并不大,所以直接安装到C盘就可以。

(1)GitHub直接下载
Download the latest installer for Windows (64-bit)

备用地址:https://github.com/jgm/pandoc/releases/latest

(2)Chocolatey安装(推荐)
右键管理员模式打开Powershell,然后执行命令

choco install pandoc

 
 
  • 1
1.1.2. 检查Pandoc是否安装以及安装版本
pandoc -v

 
 
  • 1
pandoc 2.16.1
Compiled with pandoc-types 1.22.1, texmath 0.12.3.2, skylighting 0.12.1,
citeproc 0.6, ipynb 0.1.0.2
User data directory: C:\Users\hg_ac\AppData\Roaming\pandoc
Copyright (C) 2006-2021 John MacFarlane. Web:  https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.

 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

2. Pandoc的基本使用方法

Pandoc安装与基本使用方法详述
: https://blog.csdn.net/qq_45224889/article/details/123463037

2.1. Pandoc转换主体命令格式

.xx格式文档转换为.yy格式文档,在待转文档.xx所在路径下启动cmd或者powershell(在文件夹的导航栏输入cmd即可开启),输入

pandoc -i test.xx -o test.yy

 
 
  • 1

其中,-i为input,-o为output。-i也可以忽略不写,直接输入一下命令。

pandoc test.xx -o test.yy

 
 
  • 1

2.2. Markdown转Word文档

2.2.1. md转docx默认格式直接转换
pandoc test.md -o test.docx

 
 
  • 1
2.2.2. md转docx自定义样式转换

新建r.docx作为参考文档,自定义各级标题、正文等所需格式,输入以下命令,转换后的.docx文件将与参考文档r.docx文档样式相同。

pandoc test.md -o test.docx --reference-docx=r.docx

 
 
  • 1

2.3. Markdown转换PDF

通常Markdown编辑器配合插件都可以直接导出PDF格式文件,如Typora、VSCode等,这里讲解如何用Pandoc进行转换。默认情况下,Pandoc使用LaTex来生成PDF,所以需要安装LaTex引擎,这里推荐安装TexLive.

Texlive官方网站下载: https://www.tug.org/texlive/

Texlive2021镜像网站下载: https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/Images/

镜像网站下载速度快于官网,选择texlive.iso(4.1G)下载,下载完成后即可安装。

如果直接使用pandoc test.md -o test.pdf,则会报错,因为文档中存在中文字符,需要格外定义,通过添加XeLaTex作为排版引擎,并设置中文字体来实现。

pandoc test.md -o test.pdf --pdf-engine=xelatex -V CJKmainfont="font"

 
 
  • 1

font字体应该填写相应的英语标识,如:KaiTi(楷体)、SimSun(宋体)、FangSong(仿宋)、SimHei(黑体)等。

3. 参考

Pandoc官方使用手册: https://www.pandoc.org/MANUAL.html

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值