Search code examples
quartoreveal.jsfootnotes

How to format multiple footnotes on a single sentence in Quarto reveal.js?


This is a follow-up question.

I’m wondering how to format a series of footnotes in a reveal.js slide. For example, I would like to apply three footnotes to one sentence, like so:

test_1[1-3]

My current solution is shown on slide 2.

---
title: "test"
format: revealjs
---

## slide 1

-   test_1[^1][^2][^3]

[^1]: footnote1
[^2]: footnote2
[^3]: footnote3

## slide 2

-   test_1[^1] [^2] [^3]

[^1]: footnote1
[^2]: footnote2
[^3]: footnote3

My desired output would be like slide 3: enter image description here


Solution

  • Here is how it can be done manually. First add a class to the footnote indicators that can be used to hide them via CSS. Then add them back with the desired formatting.

    qmd file:

    ---
    title: "test"
    format: revealjs
    css: mycss.css
    ---
    
    ## slide 1
    
    -   test_1[ [^1][^2][^3] ]{.hideme}[^\[1-3\]^]{.redme}
    
    [^1]: footnote1
    [^2]: footnote2
    [^3]: footnote3
    

    mycss.css file:

    .hideme {
      display: none
    }
    
    .redme {
      color: red
    }
    

    Which results in:

    enter image description here