^[脚注] 在 R Markdown 中使用罗马数字?

发布于 2025-01-16 13:05:46 字数 445 浏览 2 评论 0原文

在 R Markdown 中使用 ^[footnote] 时,有没有办法生成罗马数字或字母,而不是数值?

谢谢!

我最初的 R Markdown 设置:

---
title: |
    | title

author: | 
        | author
        
date: date

fontsize: 9pt
output:
  beamer_presentation:
    theme: default
    slide_level: 2
    includes:
      in_header: header.tex
    keep_tex: true

linkcolor: false
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

Is there a way to generate roman numerals or letters, instead of numerical values, when using ^[footnote] in R Markdown?

Thanks!

My initial R Markdown setup:

---
title: |
    | title

author: | 
        | author
        
date: date

fontsize: 9pt
output:
  beamer_presentation:
    theme: default
    slide_level: 2
    includes:
      in_header: header.tex
    keep_tex: true

linkcolor: false
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恬淡成诗 2025-01-23 13:05:47

我认为重复的答案并没有说得很清楚,但基本上,你本身无法实现你想要的。

如果可以的话,您需要对 CSS(或 Markdown 处理器)进行一些更改,以在输出中包含罗马数字。

来自文档:

要在 Rmd 文档中包含一个或多个自定义样式表,您
可以使用 css 选项,例如

output:
  html_document:
    css: "style.css"

或者,您可以使用 css 代码块来嵌入 CSS 规则
直接在您的 Rmd 文档中

```{css, echo=FALSE}
.footnotes-list {
  list-style-type: lower-roman;
}
```

因此,假设这是您的 markdown:

Here's a simple footnote,[^i] and here's a another one.[^ii]

asdfasdf
asfdasdf

[^i]: This is the first footnote.

[^ii]: Here's the second one.

您需要创建一个名为 'styles.css' 的新文件,并向其中添加以下代码:

.footnotes-list {
  list-style-type: lower-roman;
}

这将导致一些 HTML 渲染,例如这个(见下面的演示)

/* need to add this to your CSS */

.footnotes-list {
  list-style-type: lower-roman;
}
<p>
  Here’s a simple footnote,<sup class="footnote-ref">
  <a href="#fn1" id="fnref1">i</a></sup> and here’s a another one.
  <sup class="footnote-ref"><a href="#fn2" id="fnref2">ii</a></sup>
</p>

<div class="cl-preview-section">
  <p>asdfasdf<br> asfdasdf
  </p>
  <hr class="footnotes-sep">
  <section class="footnotes">
    <ol class="footnotes-list">
      <li id="fn1" class="footnote-item">
        <p>This is the first footnote. <a href="#fnref1" class="footnote-backref">↩︎</a></p>
      </li>
      <li id="fn2" class="footnote-item">
        <p>Here’s the second one. <a href="#fnref2" class="footnote-backref">↩︎</a></p>
      </li>
    </ol>
  </section>
</div>

I think the duplicate answer does not make it very clear but basically, you cannot achieve what you want natively.

If you are able, you need to add some changes to your CSS (or Markdown processor somewhere) to include the roman numerals at the output for you.

From the docs:

To include one or multiple custom stylesheets in an Rmd document, you
can use the css option, e.g.,

output:
  html_document:
    css: "style.css"

Alternatively, you can use a css code chunk to embed the CSS rules
directly in your Rmd document

```{css, echo=FALSE}
.footnotes-list {
  list-style-type: lower-roman;
}
```

So, let's say this is your markdown:

Here's a simple footnote,[^i] and here's a another one.[^ii]

asdfasdf
asfdasdf

[^i]: This is the first footnote.

[^ii]: Here's the second one.

You need to create a new file called 'styles.css' and add the following code to it:

.footnotes-list {
  list-style-type: lower-roman;
}

This would result in some HTML rendering like this (see demo below)

/* need to add this to your CSS */

.footnotes-list {
  list-style-type: lower-roman;
}
<p>
  Here’s a simple footnote,<sup class="footnote-ref">
  <a href="#fn1" id="fnref1">i</a></sup> and here’s a another one.
  <sup class="footnote-ref"><a href="#fn2" id="fnref2">ii</a></sup>
</p>

<div class="cl-preview-section">
  <p>asdfasdf<br> asfdasdf
  </p>
  <hr class="footnotes-sep">
  <section class="footnotes">
    <ol class="footnotes-list">
      <li id="fn1" class="footnote-item">
        <p>This is the first footnote. <a href="#fnref1" class="footnote-backref">↩︎</a></p>
      </li>
      <li id="fn2" class="footnote-item">
        <p>Here’s the second one. <a href="#fnref2" class="footnote-backref">↩︎</a></p>
      </li>
    </ol>
  </section>
</div>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文