r - 如何在 Rpres (R Presentation) 幻灯片中添加全屏背景图片?

标签 r rstudio reveal.js slidify rpres

我想在使用 Rstudio 创建的 R Presentation (Rpres) 幻灯片组中的一张或多张幻灯片中添加全屏背景图像。我知道 Rstudio 的 R Presentation 幻灯片使用 reveal.js 框架来获得所有漂亮的视觉效果,而我最接近实现我想要的效果的方法是按照此处的示例: https://www.uvm.edu/rsenr/vtcfwru/R/fledglings/14_Slideshows.html 并在幻灯片开始前添加以下行:

--- &slidebg bg:url(atlas.png);background-size:cover
### Introduction: about this talk

Blah blah blah...

但是,虽然我看到了图像,但它没有居中并且图像仅覆盖了可用的文本区域——也就是说,图像似乎被裁剪了并且图像周围有很大的边距。如果有办法使图像居中并删除图像周围的边距,我就会得到我想要的。我宁愿不必在编写 Rpres 文件后破解 html。此外,我宁愿不必在 html 中重新编码我的幻灯片——我喜欢能够在 Rstudio 中以 Markdown 创建我的幻灯片。

我确实尝试遵循此处的建议: Rpresentation in Rstudio - Make image fill out the whole screen 具体来说,关于使用 http://github.com/regisb/reveal.js-fullscreen-img 的评论但我无法让它发挥作用——建议的解决方案不能很好地处理 Rpres 文件,或者 README 中的信息不足以让我拼凑出一个问题来让它发挥作用。

这似乎是一个非常简单的请求。向幻灯片添加背景图像这样简单的事情肯定不会这么难吧?有什么想法吗?

最佳答案

按照这里的另一个答案:Rstudio 0.98.1028 add background image only to title slide

您可以拥有一个包含您的图像作为背景的自定义 css 文件。我们称它为 css-file.css:

<style>
/* Your other css */
    body {
      background-image: url(http://goo.gl/yJFbG4);
      background-position: center center;
      background-attachment: fixed;
      background-repeat: no-repeat;
      background-size: 100% 100%;
    }
.section .reveal .state-background {
    background-image: url(http://goo.gl/yJFbG4);
    background-position: center center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-size: 100% 100%;
}
</style>

您可以将其包含在 .Rpres 文件的开头:

test
========================================================
author: 
date: 
css:css-file.css

这应该会在标题页上为您提供背景图片,并且对后续页面进行一些编辑。

喂!

关于r - 如何在 Rpres (R Presentation) 幻灯片中添加全屏背景图片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34090164/

相关文章:

org-mode - 更改 org-reveal 导出中源代码的字体大小

r - 通过应用避免循环 - 值得麻烦吗?

r - RStudio独立连接到HDFS

r - 在 ggplot2 中使面标签水平

r - 在RStudio中等待用户响应

r - r : pandas not found 中的 python

r-markdown - 在 Rmarkdown 中从 YAML 调整 Reveal.initialize

css - 如果我将背景设为半透明,列表编号将变为半透明

R 使用 rename_with() 用通配符重命名多个列

r - 在r中导入不规则数据