pandoc转换含中文Markdown为pdf报错There is no 鍒?pandoc.exe: <stderr>: hPutChar: invalid argument (Invalid)

引言

利用pandoc转换Markdown为pdf,其实官方给出了解决方法,在Windows上cmd我的命令为:

pandoc srs.md -o srs.pdf --pdf-engine=xelatex -V mainfont=‘SimSun’

出现了warning, pdf也没有输出出来

[WARNING] Missing character: There is no 鍒?pandoc.exe: : hPutChar: invalid argument (Invalid argument)

解决方式

其实官方已经对这个问题给出了解答:

链接:Pandoc with Chinese

1.Use the following command to produce your pdf file (reference here):

pandoc srs.md -o srs.pdf --pdf-engine=xelatex -V CJKmainfont=KaiTi

2.Add the following setting to your markdown file

---
CJKmainfont: KaiTi
---

Then use

pandoc --pdf-engine=xelatex test.md -o test1.pdf

to generate the pdf file.

3.You can use ctexart class and do not need to manually designate a font (the package will do it for you). Add the following setting to

your markdown file

--- documentclass:
- ctexart
---

The pdf-generating command is the same as second way.

其他注意事项

1.查看电脑安装了拿些中文字体,在命令行窗口输入:

fc-list :lang=zh

2.如果中文字体有空格,字体还要用双引号引起来,比如:

pandoc srs.md -o srs.pdf --pdf-engine=xelatex -V CJKmainfont=‘Microsoft YaHei’

3.中文字体也可以直接输中文,同样用引号引起来,比如

pandoc srs.md -o srs.pdf --pdf-engine=xelatex -V CJKmainfont=‘微软雅黑’

4.既设置中文(用)又设置英文

pandoc srs.md -o srs.pdf --pdf-engine=xelatex -V CJKmainfont=‘微软雅黑’ -V mainfont=‘Times New Roman’

其他参考

[1]纯文本做笔记 — 使用 Pandoc 把 Markdown 转为 PDF 文件
[2]使用 Pandoc 实现 Markdown 文件转 PDF 文件

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值