Markdown 文档转 PDF

如果要生成目录, 并且目录要带上页数,可以在 markdown 文档的开头加入了属性值:

---
title: 'The Grand AI Lexicon'
author: 'Kellen Sun'
date: 'July, 2025'
mainfont: 'Times New Roman'
cjkmainfont: 'Microsoft YaHei'
monofont: 'Doulos SIL'
documentclass: book
classoption: twoside
fontsize: 11pt
geometry:
  - "paperwidth=6in"
  - "paperheight=9in"
  - "inner=0.75in"
  - "outer=0.5in"
  - "top=0.75in"
  - "bottom=1in"
toc: true
number-sections: true
toc-depth: 1

header-includes: |
  \usepackage{tipa}
  \usepackage{fontspec}
  \usepackage{xeCJK}
  \setCJKmainfont{Microsoft YaHei}
  \setCJKmonofont{Doulos SIL}
  \setcounter{tocdepth}{1}
  \usepackage{fancyhdr}
  \pagestyle{fancy}
  \fancyhf{}
  \fancyfoot[CE,CO]{\thepage}
  \renewcommand{\headrulewidth}{0pt}
  \renewcommand{\footrulewidth}{0pt}
  \usepackage{enumitem}
  \setlist[itemize,1]{label=$\bullet$}  
  \setlist[itemize,2]{label=$\circ$}   
  \setlist[itemize,3]{label=$\ast$}   
---

之后在终端执行命令

pandoc AI_lexicon_20250726.md -o AI_lexicon_20250726.tex -s  --from markdown+hard_line_breaks --table-of-contents
xelatex mybook.tex

如果有无法转换的字符, 可以在 mybook.log 中查找 missing character , 看是哪个字符转换不了, 用 Latex 语法替换修改后再次执行命令转换。

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

推荐阅读更多精彩内容