Featured image of post 使用 Pandoc 將含中文的 MarkDown 檔案轉換成 PDF 文件

使用 Pandoc 將含中文的 MarkDown 檔案轉換成 PDF 文件

📌 Introduction

分享使用 Pandoc 將 Markdown 檔案轉換成 LaTeX 格式的 PDF 文件。

🗒️ Notes

  1. 需要在 Markdown 檔案的最前面(原本檔案的第一行前面)加入以下註釋(包含前後的 ---)。
---
header-includes:
  - \usepackage{fontspec}
  - \setmainfont{PingFang SC}  # Or another CJK-supporting font installed on your system
  - \XeTeXlinebreaklocale "zh"   # Set line breaks for Chinese
  - \XeTeXlinebreakskip = 3pt plus 1pt
---
  1. 轉換成 PDF 的 Pandoc 指令
$ pandoc -o test.pdf --pdf-engine=xelatex test.md

 

Licensed under CC BY-NC-SA 4.0
Last updated on Oct 16, 2024 07:00 CST