返回顶部
m

md2pdf

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 PDF, render a report as PDF, export notes to PDF, or generate a printable document from markdown. Handles $...$ inline and $$...$$ display math, code blocks, tables, and mixed CJK/Latin text. Requires pandoc + texlive-xetex.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
632
下载量
0
收藏
概述
安装方式
版本历史

md2pdf

# 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 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: ```bash 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: ```latex \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 | Problem | Fix | |---------|-----| | Missing character warnings | Check `fc-list :lang=zh` for available CJK fonts; install `fonts-noto-cjk` if needed | | `xelatex not found` | Install `texlive-xetex` | | PDF has no math rendering | Ensure markdown uses `$...$` / `$$...$$` (not HTML math tags) | | Broken table layout | Simplify table or add `-V geometry:margin=15mm` for more width |

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 md2pdf-xelatex-1776420079 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 md2pdf-xelatex-1776420079 技能

通过命令行安装

skillhub install md2pdf-xelatex-1776420079

下载 Zip 包

⬇ 下载 md2pdf v1.0.0

文件大小: 3.83 KB | 发布时间: 2026-4-17 20:04

v1.0.0 最新 2026-4-17 20:04
Initial release: Pandoc+XeLaTeX, native LaTeX math rendering, CJK auto-detect, emoji sanitization, auto TOC generation

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部