AgentSkillsCN

md-slides

将 Markdown 转换为多种格式的演示文稿幻灯片(PDF、PPTX、HTML)。当用户提到幻灯片、演示文稿、Marp、Beamer,或希望从 Markdown 生成 PDF/PPTX 时,可使用此技能。支持多种风格(面向观众、风格偏好、语言选择),并提供视觉对比效果。

SKILL.md
--- frontmatter
name: md-slides
description: Convert Markdown to presentation slides in multiple formats (PDF, PPTX, HTML). Use when user mentions slides, presentations, Marp, Beamer, or wants to generate PDF/PPTX from markdown. Supports flavors (audience, style, language) and visual comparisons.
allowed-tools: Read, Write, Edit, Bash, Glob, Grep

Markdown Universal Slides Generator

Convert Markdown source files to presentation slides in multiple formats.

First Step: Always read and apply a visual template from templates/visual/ before generating slides. This ensures consistent visual output.

Core Concept

One source, multiple outputs:

code
slides.md → Marp/Pandoc/python-pptx → PDF / PPTX / HTML

Slide Flavors

When creating slides, ask or infer these parameters to customize output:

Audience Types

AudienceCharacteristics
managerExecutive summary, key metrics, recommendations, minimal technical details
developerCode examples, technical details, implementation specifics
learnerStep-by-step explanations, examples, progressive complexity
generalBalanced, accessible language, visual explanations

Visual Styles

StyleThemeCharacteristics
professionalgaiaClean, corporate colors, structured layouts
minimaldefaultSimple, lots of whitespace, focus on content
visualgaia + custom CSSRich graphics, comparisons, diagrams, screenshots
academicBeamer metropolisFormal, math-friendly, citations

Language Options

OptionUsage
zhChinese content, Chinese-friendly themes
enEnglish content
mixedBilingual titles/subtitles

Content Density

LengthSlidesBullets per slide
brief5-83-4
standard10-154-6
detailed20+5-8

Flavor Examples

Manager presentation (Chinese):

yaml
audience: manager
style: professional
language: zh
length: standard

→ Use Gaia theme, executive summary, key findings, recommendations

Technical tutorial (English):

yaml
audience: developer
style: minimal
language: en
length: detailed

→ Use default theme, code examples, step-by-step

Research showcase:

yaml
audience: general
style: visual
language: mixed
length: standard

→ Use Gaia with custom CSS, screenshots, comparisons

Prerequisites Check

Before generating output, verify required tools are installed:

ToolCheckLinuxmacOS
Marpmarp --versionnpm i -g @marp-team/marp-clibrew install marp-cli
Pandocpandoc --versionsudo apt install pandocbrew install pandoc
XeLaTeXxelatex --versionsudo apt install texlive-fullbrew install --cask mactex
pdftoppmpdftoppm -vsudo apt install poppler-utilsbrew install poppler

Workflow:

  1. Check if required tool exists before running
  2. If missing, detect OS (uname -s) and show install command
  3. After install, verify with version check

Available Tools & Best Use Cases

ToolBest ForOutput FormatsCommand
MarpModern slides, LLM workflowsPDF, PPTX, HTMLmarp input.md -o output.{pdf,pptx,html}
Pandoc BeamerAcademic, math-heavyPDFpandoc input.md -t beamer --pdf-engine=xelatex -o output.pdf
Pandoc PPTXEditable PowerPointPPTXpandoc input.md -o output.pptx
reveal.jsWeb presentationsHTMLpandoc input.md -t revealjs -s -o output.html

Quick Commands

Generate with Marp (Recommended)

bash
# PDF output
marp slides.md -o slides.pdf

# PPTX output
marp slides.md -o slides.pptx

# HTML output
marp slides.md -o slides.html

# With custom theme
marp slides.md --theme gaia -o slides.pdf

# Allow local images
marp slides.md -o slides.pdf --allow-local-files

Generate with Pandoc Beamer

bash
# Basic PDF
pandoc slides.md -t beamer -o slides.pdf

# With XeLaTeX (better font support, required for CJK)
pandoc slides.md -t beamer --pdf-engine=xelatex -o slides.pdf

# With theme
pandoc slides.md -t beamer -V theme:metropolis -o slides.pdf

# CJK support
pandoc slides.md -t beamer --pdf-engine=xelatex \
  -V mainfont="Noto Sans CJK SC" -o slides.pdf

Generate with reveal.js

bash
pandoc slides.md -t revealjs -s -o slides.html
pandoc slides.md -t revealjs -s -V theme=moon -o slides.html

Visual Templates (Visual Consistency)

IMPORTANT: Before generating slides, always use a visual template for consistent rendering.

Visual templates are in templates/visual/:

  • default-zh.md — Chinese slides
  • default-en.md — English slides

How to Use

  1. Read the appropriate template: templates/visual/default-{lang}.md
  2. Copy its frontmatter exactly (don't modify)
  3. Follow the gotchas listed in the template

Quick Reference (Chinese)

yaml
---
marp: true
theme: default
paginate: true
size: 16:9
style: |
  section {
    font-family: 'Noto Sans CJK SC', 'Microsoft YaHei', sans-serif;
  }
  section.small-table table { font-size: 0.85em; }
---

Rules for Consistent Output

RuleReason
Use frontmatter exactly as providedEnsures consistent rendering
Keep font stack as 'Noto Sans CJK SC', 'Microsoft YaHei', sans-serifConsistent date/number rendering
End slides with content, not directivesClean final page
Use <!-- _class: lead --> only on title slideProper centering where needed

Custom Looks

Users can add custom visual templates to templates/visual/. See templates/visual/README.md.


Markdown Slide Format

Marp Format

markdown
---
marp: true
theme: default  # or gaia, uncover
paginate: true
---

# Slide Title

Content here

---

# Next Slide

- Bullet points
- More content

Pandoc/Beamer Format

markdown
---
title: Presentation Title
author: Author Name
date: 2026
---

# Section Title

## Slide Title

- Content
- More content

---

## Another Slide

Content continues

Generating Visual Showcases

When user wants to compare tools visually:

  1. Create sample slides with representative content:

    • Title slide with Chinese/English
    • Code highlighting example
    • Math formulas
    • Tables
  2. Generate outputs from all tools:

    bash
    # Marp outputs
    marp sample.md -o output/marp.pdf
    marp sample.md -o output/marp.pptx
    
    # Beamer outputs
    pandoc sample.md -t beamer --pdf-engine=xelatex -o output/beamer.pdf
    
    # Pandoc PPTX
    pandoc sample.md -o output/pandoc.pptx
    
  3. Create screenshots for comparison:

    bash
    pdftoppm -png -f 1 -l 1 -r 150 output/marp.pdf screenshots/marp
    pdftoppm -png -f 1 -l 1 -r 150 output/beamer.pdf screenshots/beamer
    
  4. Build comparison presentation with embedded screenshots

Tool Selection Guide

ScenarioRecommended Tool
LLM/Agent automationMarp
Academic/Math-heavyPandoc Beamer
Editable PPTX neededPandoc PPTX or python-pptx
Web presentationreveal.js
Enterprise templatespython-pptx
Quick prototypingMarp

LLM Integration Pattern

python
import subprocess

def generate_slides(content: str, output_path: str):
    """Generate slides from LLM-produced content."""
    md_content = f"""---
marp: true
theme: gaia
paginate: true
---

{content}
"""
    with open("/tmp/slides.md", "w") as f:
        f.write(md_content)

    subprocess.run(["marp", "/tmp/slides.md", "-o", output_path], check=True)
    return output_path

Troubleshooting

IssueSolution
Chinese characters broken (Beamer)Use --pdf-engine=xelatex with CJK font
Images not loading (Marp)Add --allow-local-files flag
PPTX too large (Marp)Normal - Marp embeds resources
Math not rendering (reveal.js)Add --mathjax flag

Reference Files

  • Sample Markdown: docs/sample-universal.md
  • Marp-specific sample: docs/sample-marp-format.md
  • Research report: docs/report-research-zh.md
  • Showcase presentation: docs/presentation-showcase-zh.md