Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chaojian-zhang/4dfce09ad9cf32b7c2d262384108d1ea to your computer and use it in GitHub Desktop.
Save chaojian-zhang/4dfce09ad9cf32b7c2d262384108d1ea to your computer and use it in GitHub Desktop.
Convert Markdown to PDF within Sublime Text using Pandoc
{
"cmd": ["pandoc --pdf-engine=xelatex --filter=pandoc-citeproc -o '$file_base_name.pdf' '$file_name'"],
"selector": "text.html.markdown",
"shell": true
}
@chaojian-zhang
Copy link
Author

chaojian-zhang commented Jan 9, 2020

A functional version for Chinese and Unicode symbols, on Windows:

{
	"shell_cmd": "pandoc -N -s -f markdown+smart --filter=pandoc-citeproc --pdf-engine=xelatex -V CJKmainfont=KaiTi \"$file_name\" -o \"$file_base_name.pdf\"",
	"selector": "text.html.markdown",
	"shell": true
}

In addition, you can change the used font with mainfont and sansfont when using --pdf-engine=xelatex inside the YAML header per this thread, in case some symbols are missing:

---
author: Some Author
date: 2019-05-04
title: Font Test
mainfont: Arial
sansfont: Arial
---

Remarks:

  1. For Emoji, try SegoeUIEmoji
  2. For greater coverage try -V mainfont="DejaVu Sans" which seems absent in Windows, download here (Notice this breaks the "academic" look of default font, which seems to be from Latin Modern family)

Reference:

  1. Source of fork: https://gist.github.com/keuv-grvl/12f386624061672637997790fc2d0472
  2. For CJK fonts and font options: http://blog.baoduge.com/pdf_pandoc_command/
  3. Additional reference: https://jdhao.github.io/2019/05/30/markdown2pdf_pandoc/
  4. https://github.com/danstoner/pandoc_samples
  5. Additional configuration of typefaces of font: https://tex.stackexchange.com/questions/234786/how-to-set-a-font-family-with-pandoc
  6. Also see Font section of official Pandoc Markdown doc.
  7. Default font style:

Pandox Latex PDF Font Default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment