Marp: Markdown Presentation Ecosystem#
Marp (Markdown Presentation) is a powerful tool for creating presentations using Markdown. It converts Markdown files into slideshows, making it ideal for:
- Technical Presentations: Code snippets, diagrams, and technical content
- Documentation: Creating slide decks from existing documentation
- Academic Slides: Research presentations with math equations and citations
- Conference Talks: Professional presentations with custom themes
- Teaching Materials: Educational content with rich formatting
- GitHub Pages: Hosting presentations on the web
This tutorial covers using Marp in VS Code to create professional presentations.
Installation#
Install the Marp extension and CLI for different ways to preview and export:
# Install Marp CLI globally
npm install -g @marp-team/marp-cli
# For one-time use without installing
npx @marp-team/marp-cli@latest
# For use in a project
npm install --save-dev @marp-team/marp-cliBasic Structure#
Every Marp presentation starts with YAML front matter and uses --- to separate slides:
---
marp: true
title: My Presentation
author: Your Name
theme: default
paginate: true
---
# First Slide
Content goes here
---
## Second Slide
More contentThemes#
Marp comes with built-in themes and supports custom themes:
---
theme: default # Clean, minimal (default)
theme: gaia # Modern, beautiful
theme: uncover # Gradually revealing
---Create custom themes with CSS:
---
marp: true
---
<style>
section {
background: #fdf6e3;
color: #657b83;
}
h1 {
color: #d33682;
}
</style>Images and Backgrounds#
Marp has powerful image handling:
 # Regular image
 # Set width
 # Set height
 # Both width & height
<!-- Background image -->

 # Fit to slide
 # Cover slide
<!-- Multiple backgrounds -->

Directives#
Control presentation flow with directives:
<!-- _class: lead -->
# Title Slide
<!-- _backgroundColor: #123456 -->
Slide with custom background
<!-- _color: red -->
Red text
<!-- _footer: *Page footer* -->
Content with footer
<!-- _header: **Header** -->
Content with headerCode Blocks#
Code highlighting with language specification:
```python
def hello():
print("Hello, World!")
```
```javascript
console.log("Hello, World!");
```
```css
body {
background: #fff;
}
```Math Equations#
Marp supports math with KaTeX:
Inline math: $E = mc^2$
Block math:
$$
\frac{d}{dx}e^x = e^x
$$Tables and Lists#
Standard Markdown tables and lists work:
| Item | Cost |
| ---- | ---- |
| A | $1 |
| B | $2 |
- Bullet point
- Sub-point
- Sub-sub-point
1. Numbered list
2. Second item
- Mixed listBuilding & Exporting#
Export to various formats:
# HTML (for web)
marp slides.md -o slides.html
# PDF (for sharing)
marp slides.md --pdf
# PowerPoint
marp slides.md --pptx
# Images (PNG/JPEG)
marp slides.md --images pngWith VS Code integration:
---
marp: true
---
<!-- In VS Code, use Command Palette:
- "Marp: Export Slide Deck..."
- "Marp: Start Watch"
- "Marp: Toggle Preview"
-->Real Example: Data Design by Dialogue#
Here’s a real presentation example and slide output that shows these features in action:
---
marp: true
title: Data Design by Dialogue
author: Anand S
theme: gaia
paginate: true
---
<style>
blockquote {
font-style: italic;
}
section {
background-image: url('qr-code.png');
background-repeat: no-repeat;
background-position: top 20px right 20px;
background-size: 80px auto;
}
</style>
# Data Design by Dialogue
Content with styled quotes and background image...Best Practices#
File Organization:
presentation/ ├── slides.md # Main presentation ├── images/ # Images folder ├── themes/ # Custom themes └── package.json # Build configurationVersion Control:
.gitignore: node_modules/ dist/ *.pdf *.pptxBuild Automation:
{ "scripts": { "start": "marp -s .", "build": "marp slides.md -o dist/slides.html", "pdf": "marp slides.md --pdf --allow-local-files", "pptx": "marp slides.md --pptx" } }Responsive Design:
/* themes/custom.css */ section { font-size: calc(1.2vw + 1.2vh); }
Remember to:
- Keep slides focused and minimal
- Use consistent styling
- Test the presentation in the target format
- Include speaker notes when needed
- Optimize images before including
Common Issues#
Images Not Loading
- Use relative paths from the Markdown file
- Add
--allow-local-filesfor local images in PDF export
Font Problems
- Include web fonts in your custom theme
- Test PDF export with custom fonts
Build Errors
- Check Node.js version compatibility
- Verify all dependencies are installed
- Use
--verboseflag for debugging
Keyboard Shortcuts#
In VS Code Marp Preview:
F1then “Marp: Toggle Preview”Ctrl+Shift+V(Preview)Ctrl+K V(Side Preview)
In Presentation Mode:
F(Fullscreen)P(Presenter View)B(Blackout)
