rquartocaptionreveal.js

Add caption to image in revealjs Quarto


I would like to add a caption to an image in a revealjs slide. I tried using the alt option like describe here, but this doesn't seem to work. Here is some reproducible code:

---
format: revealjs
---

## Slide

This is an example: 

<img src="elephant.png" alt="A drawing of an elephant.">

Output:

enter image description here

As you can see there is no caption. Also using this syntax ![](elephant.png){fig-alt="A drawing of an elephant."} doesn't work. So I was wondering if anyone knows how to add a caption to an image in revealjs Quarto?


Solution

  • You can add the caption in the first pair of squared brackets:

    ---
    output: revealjs
    ---
    
    ![Here's an elephant](elephant.png)
    

    enter image description here

    The alt option is to provide alt-text to the figure so that people who can't see it still have a description, but it's not directly visible on the page.