You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为Quarto RevealJS幻灯片的标题页设置自定义页脚?

解决Quarto RevealJS标题页自定义页脚及许可证展示问题

方法一:用JS覆盖标题页页脚

先保留YAML里的全局footer配置,然后在YAML之后添加以下代码块,实现标题页页脚单独替换:

<script>
document.addEventListener('DOMContentLoaded', function() {
  // 定位第一页(标题页)
  const titleSlide = document.querySelector('.reveal .slides > section:first-child');
  // 创建自定义许可证页脚
  const licenseFooter = document.createElement('div');
  licenseFooter.className = 'footer';
  licenseFooter.textContent = 'CC BY-SA';
  titleSlide.appendChild(licenseFooter);
  // 隐藏标题页的全局页脚
  const globalFooter = titleSlide.querySelector('.footer');
  if (globalFooter && globalFooter.textContent === 'My global footer') {
    globalFooter.style.display = 'none';
  }
});
</script>

这段代码会复用模板自带的footer样式,确保和全局页脚的显示风格一致。

方法二:直接在标题页插入许可证文本(最简便)

不需要修改全局配置,直接在标题页末尾添加带定位样式的文本块:

---
title: "My Title"
author:
  - name: "John Doe"
date: "2023-06-30"
date-format: long
format: inrae-revealjs
draft: true
footer: "My global footer"
bibliography: references.bib
---

::: {style="position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); font-size: 0.8em;"}
CC BY-SA
:::

这段代码会在标题页底部居中显示许可证信息,不会干扰其他页面的全局页脚。

方法三:分区设置页脚

如果模板支持自定义分区页脚,可以去掉YAML中的全局footer,然后分别给标题页和其他页面设置:

---
title: "My Title"
author:
  - name: "John Doe"
date: "2023-06-30"
date-format: long
format: 
  inrae-revealjs:
    draft: true
bibliography: references.bib
---

<!-- 标题页专属页脚 -->
::: footer
CC BY-SA
:::

---

<!-- 从第二页开始的全局页脚 -->
::: {.slide-footer}
My global footer
:::

## 幻灯片内容
这里是第二页的展示内容...

注意部分模板可能需要调整.slide-footer的类名,确保样式匹配模板的页脚样式。

内容的提问来源于stack exchange,提问作者Midoux

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 15:07:11