使用pandoc将markdown、html转换到pdf

  • 系统:macOs Sierra 10.12.6

安装

  1. pandoc 安装
  2. MacTeX 安装

得到xelatex路径:
/Library/TeX/texbin/xelatex

常用命令

  1. markdown、html生成pdf
//test.md为你需要转换的markdown或html文件
$:pandoc test.md --latex-engine=/Library/TeX/texbin/xelatex -V CJKmainfont='STHeitiSC-Light'  -o example13.pdf
  1. md->html
$pandoc -f markdown -t html -o demo.html demo.md
  1. 章节标题生成超文本书签(--toc)(带书签PDF)
$ pandoc -N -s --toc --smart --latex-engine=/Library/TeX/texbin/xelatex -V CJKmainfont='PingFang SC' -V mainfont='Monaco' -V geometry:margin=1in test.md  -o output.pdf

//**注意事项,中文显示需要在命令中指定字体(CJKmainfont),使用字体的PostScript 名称**

PostScript查看方式:在mac 字体册 应用中查看,如下图:

生成的pdf预览:

QQ20171104-200604@2x.png

参考https://www.zhihu.com/question/20849824
参考https://www.zhihu.com/question/22906637/answer/32816910

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容