可以使用revealjs::revealjs_presentation 中的includes 参数/参数在所有幻灯片上添加固定页脚。 (非常感谢之前的评论者的建议让我想到了这一点)。
例如,我想为每张幻灯片添加公司徽标和免责声明页脚。我创建了一个 HTML 文件,包含在文档正文之前,内容如下:
<div id="header-footer">
<img class="slide-logo" src="corporate-logo.png"/>
<p class="slide-footer">Corporate disclaimer</p>
</div>
然后我在我的 R markdown 文档(Rmd 文件)的 YAML 标头中包含了这个带有 includes 参数的文档正文之前的 sn-p:
output:
revealjs::revealjs_presentation:
css: styles.css
includes:
in_header: header.html
然后,为了将徽标放置在右上角并将页脚固定在每张幻灯片的底部,我使用了以下 CSS(存储在 styles.css):
/********** Customise logo, and footer disclaimer **********/
/* Position the corporate logo in the top right of the page */
#header-footer .slide-logo {
position: absolute;
top: 15px;
right: 50px;
height: 60px;
width: 150px;
}
/* Style/position the footer text */
#header-footer .slide-footer {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 10px;
text-align: center;
font-size: 65%;
}
当然,您可以使用 CSS 来设置您喜欢的样式。
一个限制是,这会将徽标和页脚放置在每张幻灯片上,包括标题(但具有整个幻灯片背景图像的幻灯片除外,它隐藏了免责声明和徽标)。我目前正在尝试找出一种方法来限制某些幻灯片的徽标/免责声明。
我还没有这样做,但是应该可以将其包装到自定义模板中,以直接与您组织的新 RMarkdown 文档集成,例如在RMarkdown book 中查看第 17 章和第 18 章。
我希望这对你/其他人仍然有用。