✓ Verified 💻 Development ✓ Enhanced Data

Md2pdf Xelatex

Convert Markdown files to PDF with full LaTeX math formula rendering and CJK (Chinese/Japanese/Korea

Rating
4.8 (485 reviews)
Downloads
1,808 downloads
Version
1.0.0

Overview

Convert Markdown files to PDF with full LaTeX math formula rendering and CJK (Chinese/Japanese/Korean) support.

Complete Documentation

View Source →

md2pdf

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

Prerequisites

System packages (apt):

text
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

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

Installation

Terminal bash

openclaw install md2pdf-xelatex
    
Copied!

💻Code Examples

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

bash-skilldirscriptsmd2pdfsh-inputmd-outputpdf.txt
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:
example.sh
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"

Tags

#devops_and-cloud

Quick Info

Category Development
Model Claude 3.5
Complexity One-Click
Author huaruoji
Last Updated 3/10/2026
🚀
Optimized for
Claude 3.5
🧠

Ready to Install?

Get started with this skill in seconds

openclaw install md2pdf-xelatex