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.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "md2pdf" with this command: npx skills add huaruoji/md2pdf-xelatex

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

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Wangdongjie Cfo Skill

基于王东杰26年实战经验,提供A+H双市场IPO操盘、资本杠杆设计、业财融合和AI数字化风控咨询。

Registry SourceRecently Updated
General

Hk Stock Morning Report

Generate HK stock market morning report (股市晨報) for Chinese bank trading desk. Use when user asks "生成晨报", "股市晨报", "今日股市", "港股晨報", or any similar HK stock mark...

Registry SourceRecently Updated
General

Nansen Mpp Payment

Pay-per-call access to the Nansen API via MPP (Tempo). Use when a user wants anonymous Nansen access without an API key and without managing their own Base/S...

Registry SourceRecently Updated
General

Etsy Autolist

Auto-create and manage digital product listings on Etsy. Creates listings from existing digital product files (PDFs, templates, spreadsheets) using Etsy Open...

Registry SourceRecently Updated