在 R Markdown 演示文稿中覆盖 reveal.js
Override reveal.js in R Markdown presentation
我正在尝试在 rmarkdown 中整合一个 reveal-js 演示文稿,但无法覆盖默认的 css 主题。我想从我的绘图图像中删除边框。根据文档,这应该有效:
但它并没有,我猜这是因为这个覆盖不是更具体。但我的问题是我通常增加特异性的方法也不起作用:
## Slide with Plot
<section class = "no-border">
```{r pressure}
plot(pressure)
```
</section>
这是YAML-header:
title: "Title"
author: "..."
date: '`r paste(format(Sys.Date(),"%d")," ", mymonths[sys.man], ", ",
format(Sys.Date(),"%Y"), sep = "")`'
output:
revealjs::revealjs_presentation:
incremental: true
includes:
in_header: slidy_bootstrap_header.html
css: slidyStandard.css
这是 css-override:
section.no-border > img {
background:none;
border:none;
box-shadow:none;
}
有人知道我做错了什么吗?
问题似乎是,您的 <section>
标记没有环绕源代码及其输出。你可以做的是 jQuery:
---
title: "Title"
author: "..."
output:
revealjs::revealjs_presentation:
incremental: true
includes:
css: slidyStandard.css
---
<!-- Include jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<!-- Add class to img elements -->
<script type="text/javascript">
$(document).ready(function() {
$elms = $('p > img');
$elms.addClass('no-border');
});
</script>
<!-- define no-border class -->
<style>
.no-border {
border: 0px !important;
}
</style>
```{r pressure}
plot(pressure)
```
我意识到我在 YAML-header 中把 custom-css 放错了地方。因此,它没有用。
下面是自定义的可重现代码 css:
---
title: "Untitled"
output:
revealjs::revealjs_presentation:
css: custom2.css
---
## R Markdown
This is an R Markdown presentation. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.
## Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
## Slide with R Code and Output
```{r}
summary(cars)
```
## Slide with Plot
```{r, echo=FALSE}
plot(cars)
```
和 css:
.reveal section img {
margin: 15px 0px;
background: rgba(255, 255, 255, 0.12);
border: none;
box-shadow: none;
}
我正在尝试在 rmarkdown 中整合一个 reveal-js 演示文稿,但无法覆盖默认的 css 主题。我想从我的绘图图像中删除边框。根据文档,这应该有效:
但它并没有,我猜这是因为这个覆盖不是更具体。但我的问题是我通常增加特异性的方法也不起作用:
## Slide with Plot
<section class = "no-border">
```{r pressure}
plot(pressure)
```
</section>
这是YAML-header:
title: "Title"
author: "..."
date: '`r paste(format(Sys.Date(),"%d")," ", mymonths[sys.man], ", ",
format(Sys.Date(),"%Y"), sep = "")`'
output:
revealjs::revealjs_presentation:
incremental: true
includes:
in_header: slidy_bootstrap_header.html
css: slidyStandard.css
这是 css-override:
section.no-border > img {
background:none;
border:none;
box-shadow:none;
}
有人知道我做错了什么吗?
问题似乎是,您的 <section>
标记没有环绕源代码及其输出。你可以做的是 jQuery:
---
title: "Title"
author: "..."
output:
revealjs::revealjs_presentation:
incremental: true
includes:
css: slidyStandard.css
---
<!-- Include jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<!-- Add class to img elements -->
<script type="text/javascript">
$(document).ready(function() {
$elms = $('p > img');
$elms.addClass('no-border');
});
</script>
<!-- define no-border class -->
<style>
.no-border {
border: 0px !important;
}
</style>
```{r pressure}
plot(pressure)
```
我意识到我在 YAML-header 中把 custom-css 放错了地方。因此,它没有用。
下面是自定义的可重现代码 css:
---
title: "Untitled"
output:
revealjs::revealjs_presentation:
css: custom2.css
---
## R Markdown
This is an R Markdown presentation. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.
## Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
## Slide with R Code and Output
```{r}
summary(cars)
```
## Slide with Plot
```{r, echo=FALSE}
plot(cars)
```
和 css:
.reveal section img {
margin: 15px 0px;
background: rgba(255, 255, 255, 0.12);
border: none;
box-shadow: none;
}