使用 Rmarkdown 和 revealjs 在每张幻灯片中添加页脚
Including a footer an every slide with Rmarkdown and revealjs
我的公司要求所有内部+外部演示文稿都为每张幻灯片使用经过批准的页脚,这迫使每个人都将内容复制并粘贴到 PowerPoint 中。
不过,我很想用 R 笔记本制作 revealjs_presentation 幻灯片。谁能提供一个 Rmarkdown 笔记本(或 pandoc 模板?)的简单示例?我可以修改它吗?
我想这对很多公司的很多人都有用。
可以使用 revealjs::revealjs_presentation
中的 includes
parameter/argument 在所有幻灯片上添加固定页脚。 (非常感谢早期评论者的建议让我想到了这个)。
例如,我想为每张幻灯片添加公司徽标和免责声明页脚。我创建了一个 HTML 文件以包含在文档 body 之前,其内容如下:
<div id="header-footer">
<img class="slide-logo" src="corporate-logo.png"/>
<p class="slide-footer">Corporate disclaimer</p>
</div>
然后我在我的 R markdown 文档(Rmd 文件)的 YAML header 中使用 includes
参数在文档的 body 之前包含了这个片段:
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 来设置您喜欢的样式。
一个限制是,这会将徽标和页脚放在 每张 幻灯片上,包括标题(但具有 whole-slide 背景图像的幻灯片除外,它隐藏了免责声明和徽标)。我目前正在尝试找出一种方法来限制某些幻灯片的 logo/disclaimer。
我还没有这样做,但是 应该 可以将其包装到自定义模板中以直接与您组织的新 RMarkdown 文档集成,例如在 RMarkdown book.
中查看第 17 章和第 18 章
我希望这对 you/others 仍然有用。
我的公司要求所有内部+外部演示文稿都为每张幻灯片使用经过批准的页脚,这迫使每个人都将内容复制并粘贴到 PowerPoint 中。
不过,我很想用 R 笔记本制作 revealjs_presentation 幻灯片。谁能提供一个 Rmarkdown 笔记本(或 pandoc 模板?)的简单示例?我可以修改它吗?
我想这对很多公司的很多人都有用。
可以使用 revealjs::revealjs_presentation
中的 includes
parameter/argument 在所有幻灯片上添加固定页脚。 (非常感谢早期评论者的建议让我想到了这个)。
例如,我想为每张幻灯片添加公司徽标和免责声明页脚。我创建了一个 HTML 文件以包含在文档 body 之前,其内容如下:
<div id="header-footer">
<img class="slide-logo" src="corporate-logo.png"/>
<p class="slide-footer">Corporate disclaimer</p>
</div>
然后我在我的 R markdown 文档(Rmd 文件)的 YAML header 中使用 includes
参数在文档的 body 之前包含了这个片段:
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 来设置您喜欢的样式。
一个限制是,这会将徽标和页脚放在 每张 幻灯片上,包括标题(但具有 whole-slide 背景图像的幻灯片除外,它隐藏了免责声明和徽标)。我目前正在尝试找出一种方法来限制某些幻灯片的 logo/disclaimer。
我还没有这样做,但是 应该 可以将其包装到自定义模板中以直接与您组织的新 RMarkdown 文档集成,例如在 RMarkdown book.
中查看第 17 章和第 18 章我希望这对 you/others 仍然有用。