Tutorial: Marp for VS Code
Tags: visualcode, marp, pdf, pptx
Published: 2023-07-14 16:15:37

I recently had a project to present that needed to create slides, I don’t know about you, but I like simplicity in the tools I use, so I’ve always had a crush on Markdown. I use it for grocery lists, I use it to organize content that I study with Obsidian, I use it to write papers, practically for several situations. That’s because I usually don’t want to have to deal with a lot of details at that moment of writing, I want to express what I have and mind and keep. That’s why [Markdown](https://www.markdownguide.org) is one of my favorites.

This made me wonder, is there a tool that uses Markdown to create slides???

## Marp for VS Code

oooohhhh!!! It existed. After some web searches I found it. Simple tool but with an absurd level of power that you will learn about in this tutorial. Here’s the project link below for more details, don’t forget to give it a star on Github.

{% embed https://github.com/marp-team/marp-vscode %}

{% embed https://marp.app %}

Here are some options you can use:

- Create slides from a Markdown file
- Add images
- Text formatting
- Positioning elements on the slide
- Exports in different file types (HTML, PDF, PPTX, PNG, JPEG)

I think this is very good, because let’s put it in context, imagine that you are a student at a course or college. You need to create a presentation about your code under development. By using Markdown you were able to place blocks of code in the presentation, this is very useful because there are platforms that you could not place and not even with indentation. In addition, VS Code can place a markdown viewer and be able to open another window with code files, follow your presentation.


![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9b7618vciiau4u5tv5cv.png)

In addition, we can create versioning in our slides. Creating a repository on [GitLab](https://about.gitlab.com) or [Github](https://github.com).

Another example is being able to prepare several slides for a course, due to its simplicity, you don’t have to worry about many details.


![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yqk0s91ch4t61hl2uiei.png)

Wow amazing !!!!!!!! Let’s get our hands dirty.

## Where do I start in Marp?

First, you must have an integrated development environment (IDE), which is VS Code.

{% embed https://code.visualstudio.com %}


Having VS Code installed you will be able to use the Marp tool as it is an extension. No need for additional installers.

Installing extension:

1. Click on extensions
2. Search "marp"
3. Click on the "Marp for VS Code" extension.
4. Click on install.



![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lkn0d7swkb3pbvnxifjp.png)

After these steps we will create a blank Markdown file.


![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qy0fdpcj66mhuo6qftnd.png)

I named my file “my_first_marp.md”. From that point we can already develop.
Observer to type something in my file. Then click on the magnifying glass icon. To view the result.


![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9mme9rs6i2bl7ese7fuu.png)

But where are the slides?


![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bftj1nj36ys291yhgp0c.png)

In order to work with Marp, we have to add a parameter in our Markdown file.

```text
---
marp: true
---

```

By inserting this parameter at the beginning of the file, we can see that we have a slide. Note the simplicity, we declared “marp” and passing the argument as “true”, we already transformed our file.


![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w4cw8tf7hetkdh0jxrtq.png)


So everything that has an interpretation being Markdown will result in the slide.
Like the example below:


![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vkm8ah2glfsb8fjugzt1.png)


For the slide I used:

- #: For Title
- ##: For the subtitle
- To add texts you don’t need a tag, you just need to type, respect where you have a tag. At this point I just added some Lorem Ipsum text. To populate the slide.
- []() : To add links to my file.

After you have created your first Markdown file and also your first Marp. You will reach a point where you will need to add more slides to your presentation.

After you are finished placing your content on the slide. To move on to the next one just add at the end:

```text
---

```

With that you have a new slide and you can now add new content.

Our current code looks like this:

```text
---
marp: true

---

## Tutorial

## Marp Visual Code

Pariatur occaecat duis commodo culpa dolor cillum. Laboris ut qui nisi cupidatat ipsum occaecat mollit proident minim occaecat esse ut ut do. Do est proident nostrud do aute aute culpa pariatur. Excepteur nisi velit eiusmod tempor in. Pariatur nisi veniam nostrud commodo excepteur tempor aliqua pariatur ad velit nulla.

[Marp](https://marp.app)

---

## Create first slide

Use this:


"---"
"marp: true"
"---"

## Second Slide

Use this:



"---"

Fugiat pariatur amet fugiat id deserunt quis proident culpa duis qui.

"---"

```

## Themes

Now let’s choose a theme, let’s add “theme” along Marp’s configuration block.


![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/965eimoyq4xm8c40m648.png)

```text
---

marp: true
theme: gaia

---
```

Look simplicity to change the theme, by default Marp has:

- default
- gaia
- uncover


![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a3sq5vy4o13djgfc4rhv.png)


This one above is using the “theme: uncover”.

Notice another issue on slide 2 where the background color is different. I can also pass individual settings to slides. In this case I added that I wanted to invert the color of the slide.

```text
<!-- _class: invert -->

## Create first slide

Use this:


"---"
marp: true

"---"

```


## Images

Through Markdown we can add images, but the images will not always look the way we want.


![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jz462ln2cvwyt5h1rbr5.png)

In the image declaration itself we can configure the size


![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b9d4ybg4f4uan6galeki.png)

Observer that by adding “height and width”, we already adjust the image we want.

We can also change the position of the image, let’s say you want to add the background image to the slide.

Adding “[]” inside we can inform that we want to use a background in this image.

```text
---
<!-- _class: invert -->

## Images position

![bg](./images/image_1.png)

- Fugiat pariatur amet fugiat id</br> deserunt quis proident</br> culpa duis qui.

- Fugiat pariatur amet fugiat id</br> deserunt quis proident</br> culpa duis qui.

---
```


![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/556v7dwt25ykqnngzde7.png)

But if the image covering the entire background is not an idea, it can also be changed.

```text
---

## Images position

![bg height: 300 left:50%](./images/image_1.png)

- Fugiat pariatur amet fugiat id deserunt quis proident culpa duis qui.

- Fugiat pariatur amet fugiat id  deserunt quis proident culpa duis qui.

---

```

![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l6a1vjf2msg9tf2zao8o.png)

## Export PDF

In this step we will export our Markdown file to PDF.

- Click on the “Marp” icon.


![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u0k875nqlju20jdt1qfv.png)

- Choose the “export slide deck” option.

- If you want to export with a different name from the original file, just replace it in the window that opened. On my operating system (POP!_OS) it already opened in PDF format, if yours appears different. Just replace the format after the “ . “.

By default when installing it is as PDF.


![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g7lba9jpu6w232u5f7dk.png)

- Then click on “export”.

- It will be exported to the chosen destination folder and then the file will be opened.


![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/95jtq0hw0efkpobmp699.gif)

## Export PPTX

In this step we will export our Markdown file to PPTX.

Click on the “Marp” icon.


![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/glnw61t5292qkj3i5uxq.png)


- Choose the “export slide deck” option.

- If you want to export with a different name from the original file, just replace it in the window that opened. In my operating system (POP!_OS) it already opened in PDF format, after “ . “, I will replace it with “.pptx”. To export as slides.

- Then click on “export”.

- It will be exported to the chosen destination folder and then the file will be opened.


![Created by the author](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/70amxp8d80wnsm4yssx6.gif)

## Comments:

Thanks for reading this far. I hope I can help you understand. Any code or text errors please do not hesitate to return. Don’t forget to leave a like so you can reach more people.

## Resources

- [Tutorial Marp](https://github.com/sc0v1n0/tutorial_tool_marp)

## About the author:

{% embed https://dev.to/sc0v0ne %}

**A little more about me...**

Graduated in Bachelor of Information Systems, in college I had contact with different technologies. Along the way, I took the Artificial Intelligence course, where I had my first contact with machine learning and Python. From this it became my passion to learn about this area. Today I work with machine learning and deep learning developing communication software. Along the way, I created a blog where I create some posts about subjects that I am studying and share them to help other users.

I'm currently learning TensorFlow and Computer Vision

Curiosity: I love coffee

- [Kaggle](https://www.kaggle.com/sc0v1n0)
- [Gitlab](https://gitlab.com/sc0v0n3)
- [Github](https://github.com/sc0v0ne)
- [Mastodon](https://mastodon.social/@sc0v0ne)