Presentations Using Marp
Recently, I found myself needing to write a series of presentations for a project. I have always relied entirely on Microsoft PowerPoint to create presentations throughout my studies or for small client presentations, usually using templates from the companies I previously worked for.
In order to move away from Microsoft, I decided to look for free and open-source software that would allow me to create presentations, and I ended up choosing Marp.
What is Marp?
Marp is a tool used to generate presentations. What sets Marp apart from other slide-generation programs such as Microsoft PowerPoint or LibreOffice Impress is that presentations in Marp can be generated using Markdown documents, which significantly speeds up the presentation creation process.
An alternative to Marp that I have used on other occasions is LaTeX Beamer, which I considered using again. However, in my opinion, it does not offer the same level of customization that Marp provides.
How to use it
To use Marp, we first need to install the marp-cli utility and create a Markdown document. Once this is done, we can run the following command:
1marp --watch document.mdThis will transform our Markdown document into an HTML document that updates automatically as we modify the source file.
Preamble
First, we need to configure the initial options of the document. A basic configuration1 would look like the following:
1---
2marp: true
3paginate: true # Shows the page number
4header: 'Only in death does duty end'
5footer: 'Slides by [Gabriel Cachadiña](https://gabrielcachadina.com/)'
6size: 16:9
7
8style: |
9 @import "default";
10 @import url('https://fonts.googleapis.com/css2?family=Work+Sans&display=swap');
11
12 :root {
13 font-family: "Work Sans Regular", Arial;
14 --main-color: #040014;
15 --text-color: #121114;
16 --bg-color-alt: #dadada;
17 --mark-background: #98d6ff;
18 }Where the following is defined:
marp: Sets the document type and must therefore always be present.paginate: Used to display the slide number.header: Header text.footer: Footer text.size: Slide resolution.style:CSSstyling2
Slides
Slides are delimited by --- and are composed of elements commonly found in Markdown, HTML, and $\LaTeX$.
Indexes
Marp does not support automatic indexes (something that Beamer does), so slide jumps must be specified manually.
1---
2# Index
31. [Section 1](#1 "Section 1")
42. [Section 2](#1 "Section 2")
53. [Section 3](#1 "Section 3")
64. [Section 4](#1 "Section 4")Lists
Lists can be either unordered or ordered, and they can be presented all at once or in a fragmented way, so that items appear one by one.
1---
2# Bullet Lists
3- Item 1
4- Item 2
5- Item 3
6- Item 4
7---
8# Fragmented Lists
9* Item 1
10* Item 2
11* Item 3
12* Item 4
13---
14# Ordered Lists
151. Item 1
162. Item 2
173. Item 3
184. Item 4
19---
20# Fragmented Lists
211) Item 1
222) Item 2
233) Item 3
244) Item 4Code
When adding code, syntax highlighting can be applied using the highlightjs library.
1---
2# Code Blocks
3Some `golang` code:
4 ```go
5 package main
6
7 import "fmt"
8
9 func main() {
10 fmt.Println("hello world")
11 }
12 ```Formulas
Using $\LaTeX$ notation, Marp can render formulas via MathJax.
1---
2# Math
3
4An inline formula is $x^2=3$, while a centered one is:
5
6$$ I_{xx}=\int\int_Ry^2f(x,y)\cdot{}dydx \quad (1)$$Tables
For tables, I recommend using a Neovim plugin like easytables.
1---
2# Tables
3
4| Tables | Are | Cool |
5|----------|:-------------:|------:|
6| col 1 is | left-aligned | $1600 |
7| col 2 is | centered | $12 |
8| col 3 is | right-aligned | $1 |Images
Marp is extremely versatile when it comes to images, which is why I strongly recommend consulting the manual. Below are some examples of slides using images in ways I commonly use.
1---
2### Image Insertion
3Two images side by side:
4 ;
5---
6### YouTube Videos
7[](http://www.youtube.com/watch?v=jNQXAC9IVRw?t=35s "resist to click")
8---
9
10### Split backgrounds with specified size
11With some more text under the title
12<!--
13backgroundImage:
14backgroundColor:
15color:
16-->Multiple Columns
Currently, there is no direct way to include two text columns in Marp, at least natively. I have found the following method using CSS:
1---
2# Multiple Text Columns
3<div class="columns">
4<div>
5
6- Column
7- Number
8- 1
9
10</div>
11<div>
12
13- Column
14- Number
15- 2
16
17</div>
18</div>Speaker Notes
If needed, you can add notes that are visible only to the presenter.3
1---
2# Speaker Notes
3Inside this slide there are some speaker notes.
4<!--
5 Here lie some of the notes of this slide. I need to talk about:
6 - Speaker notes in Marp
7 - How Markdown does NOT work in these notes
8 - How this is hidden from the audience
9-->Markdown Styling
In addition to everything mentioned above, text can be formatted just like in a normal Markdown document.
1# Other stylistic markdowns for highlighting include
2- `...` from `` `...` `` using backticks
3- *italic* from `*italic*`
4- **bold** from `**bold**`
5- ~~strikethrough~~ from `~~strikethrough~~`
6- > blockquote from `>`
7- [source link](https://www.website.com) from `[source link](http://www.website.com)`
8- Some fun emojis :shit: from `:shit:` using words surrounded by colonsCompilation
Once the document is finished, it can be compiled using one of the following commands:
marp document.md– to generate anHTMLversion.marp --pdf document.md– to generate a PDF version, but animations will be lost.marp --pptx document.md– to generate a PowerPoint file. This will not be editable; it will be a series of images onto which elements can be placed.
Conclusion
Marp has a small learning curve, and its customization process is generally slower compared to other WYSIWYG programs. However, if you invest the time, it offers an excellent alternative for creating distraction-free presentations, with the added benefit that all data remains in a readable format even if the software ceases to exist.
To discover more options that can be used in the document header, consult the official usage manual ↩︎
The style is highly configurable. I recommend taking a look at an example of an extensive configuration and using the usage manual as reference. ↩︎
If you want these notes to appear in the PDF, you must compile the document using the
--pdf-notesflag. ↩︎