← 返回
效率工具 中文

md2pdf-xelatex

Convert Markdown files to PDF with full LaTeX math formula rendering and CJK (Chinese/Japanese/Korean) support. Use when the user asks to convert markdown to...
将 Markdown 文件转换为 PDF,支持完整的 LaTeX 数学公式渲染及 CJK(中文/日文/韩文)支持。
huaruoji
效率工具 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 1,188
下载
💾 133
安装
1
版本
#latest

概述

md2pdf

Convert Markdown → PDF via Pandoc + XeLaTeX. Full LaTeX math + CJK support.

Prerequisites

System packages (apt):

pandoc texlive-xetex texlive-fonts-recommended texlive-fonts-extra texlive-latex-extra texlive-lang-chinese

Quick Convert

bash <skill_dir>/scripts/md2pdf.sh input.md output.pdf

The script auto-detects CJK content, picks suitable fonts, sanitizes emoji, adds TOC, and configures XeLaTeX.

Manual Pandoc Command

For fine-grained control, run pandoc directly:

pandoc input.md -o output.pdf \
  --pdf-engine=xelatex \
  -f markdown-smart \
  -H header.tex \
  -V mainfont="DejaVu Sans" \
  -V monofont="DejaVu Sans Mono" \
  -V geometry:margin=20mm \
  -V fontsize=10pt \
  -V colorlinks=true \
  --highlight-style=tango \
  --toc -V toc-title="Table of Contents"

Where header.tex contains:

\usepackage{xeCJK}
\setCJKmainfont{<CJK font name>}

Key Details

  • Math: Pandoc natively converts $...$ (inline) and $$...$$ (display) to LaTeX math. No MathJax/KaTeX needed.
  • CJK fonts: Script auto-detects from: Noto Sans CJK SC > WenQuanYi Micro Hei > Droid Sans Fallback > AR PL UMing CN.
  • Emoji: Replaced with text equivalents ([Y], [N], *) since most LaTeX fonts lack emoji glyphs.
  • Smart quotes: Use -f markdown-smart to avoid curly quote rendering issues.
  • Long tables: Pandoc may struggle with complex tables; keep tables simple or use longtable LaTeX package.

Troubleshooting

ProblemFix
--------------
Missing character warningsCheck fc-list :lang=zh for available CJK fonts; install fonts-noto-cjk if needed
xelatex not foundInstall texlive-xetex
PDF has no math renderingEnsure markdown uses $...$ / $$...$$ (not HTML math tags)
Broken table layoutSimplify table or add -V geometry:margin=15mm for more width

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-29 10:38 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

productivity

Nano Pdf

steipete
使用nano-pdf CLI通过自然语言指令编辑PDF
★ 275 📥 114,866
productivity

Weather

steipete
获取当前天气和预报(无需API密钥)
★ 445 📥 226,323
productivity

Word / DOCX

ivangdavila
创建、检查和编辑 Microsoft Word 文档及 DOCX 文件,支持样式、编号、修订记录、表格、分节符及兼容性检查等功能。
★ 439 📥 147,737