Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use footnote multiple times in HTML Quarto

I would like to use a single footnote multiple times in HTML Quarto. The problem is that once I create a footnote and use it twice, it will be shown as two footnotes. Here is a reproducible example:

---
title: "Footnote multiple times"
editor: visual
format: html
---

Some example text for a footnote[^1].

Some example text for same footnote[^1].

[^1]: Example footnote.

Output:

enter image description here

As you can see, the footnote is shown as two separate footnotes (duplicated) while I created one footnote. So I was wondering if anyone knows how to create one footnote and use it multiple times in HTML Quarto?

like image 547
Quinten Avatar asked Oct 17 '25 05:10

Quinten


1 Answers

We can sort of mimic how quarto would have generated the html code creating for footnotes to get similar appearances (that's why I have used r function so that I don't have to write the same thing multiple times).

---
title: "Footnote multiple times"
format: html
---

```{r}
#| echo: false

gen_fn <- function(n, id) {
  # n is number of footnote
  # id is a unique id for that footnote
  paste0('<a href="#',id, '" class="footnote-ref" role="doc-noteref" aria-expanded="false"><sup>', n, '</sup></a>')
}
```

Some example text for a footnote`r gen_fn(1, "fn1")`

Some example text for same footnote`r gen_fn(1, "fn1")`

Another text containing different footnotes`r gen_fn(2, "fn2")`

```{=html}
<footer>
  <h2>Footnotes</h2>
  <ol  style="padding-left: 1rem;">
    <li id="fn1"><p>Example footnote.</p></li>
    <li id="fn2"><p>More footnote.</p></li>
  </ol>
</footer>
```

multiple references to same footnote


like image 177
Shafee Avatar answered Oct 18 '25 22:10

Shafee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!