目录

mdToPDF

This project is open-sourced on github and gitlink (China-network friendly).

A Chinese Markdown-to-PDF project based on Pandoc + LuaLaTeX.

This project is derived from and heavily adapted for Chinese from Eisvogel.

It supports a graded six-level heading scale, Chinese fake-bold / fake-italic, colorful emoji and special symbols, GitHub-style admonitions, code highlighting, tables and math formulas — ideal for turning course notes, lab reports and documents into polished, good-looking PDFs.

Features

  • Graded six-level heading scale: # to ###### step down in size, with a clear hierarchy.
  • Chinese bold / italic: AutoFakeBold / AutoFakeSlant allow synthesizing bold and italic even for fonts that lack them.
  • Colorful emoji and special symbols: uses lualatex + mainfontfallback to render Unicode characters and colorful emojis.
  • GitHub-style admonitions: the alerts.lua filter renders five colored callout blocks — note / tip / important / warning / caution.
  • Code highlighting, tables, math formulas: native Pandoc support, with the idiomatic syntax-highlighting style.
  • Title page / TOC / colored links: controlled via YAML Front Matter switches.

Directory Structure

mdToPDF/
├── src/                    # Holds the Markdown source files
│   └── example.md          # Example Markdown file
├── build/                  # Build output directory; PDFs are auto-generated by build.ps1
├── preview/                # Sample build output and its preview images
├── resources/              # Templates and resources
│   ├── latex/
│   │   ├── eisvogel.latex  # LaTeX template
│   │   └── eisvogel.beamer # beamer template
│   ├── alerts.lua          # GitHub-style admonition Lua filter
│   └── background.pdf      # Title-page / page background image
├── build.ps1               # Windows build script
└── LICENSE.md              # PolyForm Noncommercial License 1.0.0

Requirements

Component Version / Notes
Pandoc refer to one of my blog post for the installation
TeX Live refer to my another blog post for the installation
Fonts SimSun, Source Sans 3, Noto Color Emoji, FreeSans, DejaVu Sans

Font notes: SimSun is used for Chinese body text; Source Sans 3 is the Latin main font; Noto Color Emoji / FreeSans / DejaVu Sans form the emoji and special-symbol fallback chain.

Usage

One-shot build

Put your Markdown files into src/, then run the build script:

.\build.ps1

The script iterates over every *.md in src/ and produces a matching build/<name>.pdf for each.

Build script parameters:

  • Input format: markdown+alerts
  • Template: resources/latex/eisvogel.latex
  • Engine: lualatex
  • Filter: resources/alerts.lua
  • Syntax highlighting: idiomatic
  • Chinese main font: SimSun; Latin main font: Source Sans 3
  • emoji / symbol fallback chain: Noto Color EmojiFreeSansDejaVu Sans

Single-file build

pandoc .\src\example.md -o .\build\example.pdf `
  --from markdown+alerts `
  --template ".\resources\latex\eisvogel.latex" `
  --syntax-highlighting idiomatic `
  --pdf-engine "lualatex" `
  -V CJKmainfont="SimSun" `
  -V mainfont="Source Sans 3" `
  -V mainfontfallback="Noto Color Emoji:mode=harf" `
  -V mainfontfallback="FreeSans:mode=harf" `
  -V mainfontfallback="DejaVu Sans:mode=harf" `
  --lua-filter ".\resources\alerts.lua"

Writing Markdown

Front Matter

Set the title, author, table of contents, title page, etc. with a YAML block at the top of your .md file:

---
title: "标题"
author: [你的名字]
date: "2026-09-12"
subject: "Markdown"
keywords: [关键词, markdown]
subtitle: "副标题"
titlepage: true            # Enable the cover page
titlepage-rule-color: "00727c"
titlepage-background: "<absolute path>"   # Title-page background
page-background: "<absolute path>"        # Body-page background
colorlinks: true          # Color hyperlinks
block-headings: true      # Headings occupy their own line
toc: true                 # Table of contents
toc-own-page: true        # TOC on its own page
---

[!NOTE] During testing we found that using an absolute path for the background prevents a successful build. For any other questions, feel free to discuss them in the Issues section.

GitHub-style admonitions

Use the GitHub-style > [!TYPE] blockquote syntax; alerts.lua renders it as a colored block:

> [!NOTE]
> Explanation

[!NOTE] Explanation

> [!TIP]
> Tip

[!TIP] Tip

> [!IMPORTANT]
> Important

[!IMPORTANT] Important

> [!WARNING]
> Warning

[!WARNING] Warning

> [!CAUTION]
> Danger

[!CAUTION] Danger

Customization

  • Change the template: edit resources/latex/eisvogel.latex (heading sizes, fonts, colors, headers/footers, etc.).
  • Change GitHub-style admonition styles: edit resources/alerts.lua (colors, borders, title text).
  • Change the build flow: edit build.ps1.
  • Reference upstream: for other questions you can also refer to the upstream project Eisvogel.

LICENSE

This project is released under the PolyForm Noncommercial License 1.0.0.

Required Notice: Copyright 2026 jianyuewushuang jianyuewushuang@163.com

Noncommercial use is free to use, modify and distribute; for commercial use, please contact the author.

关于

通过pandoc把markdown直接转换成排版美观精致的PDF文件的latex模板。(Chinese and special character friendly)

422.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802047560号