在 HTML 四开本中多次使用脚注

Qui*_*ten 3 html cross-reference footnotes quarto

我想在 HTML 中多次使用同一个脚注Quarto。问题是,一旦我创建脚注并使用它两次,它将显示为两个脚注。这是一个可重现的示例:

---
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.
Run Code Online (Sandbox Code Playgroud)

输出:

在此输入图像描述

正如您所看到的,脚注显示为两个单独的脚注(重复),而我创建了一个脚注。所以我想知道是否有人知道如何创建一个脚注并在 HTML 四开本中多次使用它?

sha*_*fee 5

我们可以模仿 quarto 如何生成为脚注创建的 html 代码以获得相似的外观(这就是我使用 r 函数的原因,这样我就不必多次编写相同的内容)。

---
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>
```
Run Code Online (Sandbox Code Playgroud)

多次引用同一脚注