1

我想调整此处提供的 .css 文件,以便在每张幻灯片的右上角包含一个小徽标,但标题、反面和最后一张幻灯片除外。理想情况下,我可以在 .css 文件中添加一些简单的内容,而不是手动编写演示文稿的每张幻灯片。

我试着添加这个

background-image: url(https://github.com/jvcasillas/ru_xaringan/raw/master/img/logo/ru_shield.png);
  background-position: 9% 15%;
  background-size: 55px;

.remark-slide-content {
  padding-left: 100px;  /* delete this for 4:3 aspect ratio */
}

要得到

.remark-slide-content {
background-image: url(https://github.com/jvcasillas/ru_xaringan/raw/master/img/logo/ru_shield.png);
  background-position: 9% 15%;
  background-size: 55px;
  padding-left: 100px;  /* delete this for 4:3 aspect ratio */
}

图像显示在所有幻灯片上,包括标题和过渡。它甚至覆盖了 .title-slide 图像。

4

2 回答 2

3

您可以执行以下操作来排除title-slide

.remark-slide-content:not(.title-slide){
  background-image: url(https://github.com/jvcasillas/ru_xaringan/raw/master/img/logo/ru_shield.png);
  background-position: 9% 15%;
  background-size: 55px;
  padding-left: 100px;  /* delete this for 4:3 aspect ratio */
}

但这样做的缺点是,如果您在其他幻灯片中有背景图像,它将覆盖上面的图像。因此,您可能还想定义另一个类,例如exclude

.remark-slide-content:not(.exclude){
  background-image: url(https://github.com/jvcasillas/ru_xaringan/raw/master/img/logo/ru_shield.png);
  background-position: 9% 15%;
  background-size: 55px;
  padding-left: 100px;  /* delete this for 4:3 aspect ratio */
}

.logopos {
  position: absolute;
  top: 9%;
  left: 15%;
}

对于您对另一个背景图像有问题的相应幻灯片,请禁用它并手动添加它。例如

class: exclude 
background-image: url("bla")

content

<img class="logopos" src="https://github.com/jvcasillas/ru_xaringan/raw/master/img/logo/ru_shield.png">
于 2019-01-30T23:25:15.570 回答
1

最近我遇到了xaringanExtraGarrick Aden-Buie 的包,请参阅https://pkg.garrickadenbuie.com/xaringanExtra/。许多有用的功能,包括一个非常简单的徽标处理选项。你只需添加一个块

```{r xaringan-logo, echo=FALSE}
xaringanExtra::use_logo(
image_url = <fill in your path> )
```

仅此而已。

于 2020-07-10T16:45:19.487 回答