As per this answer和其他资源,我的理解是在为Rmarkdown演示文稿设置CSS时,code.r {}应该控制回显代码的参数,而pre {}应该控制输出的大小。但是,pre {}似乎正在改变它们和code.r {}什么都不做。我做错了吗?
---
title: "CSStest"
author: "Me"
date: "December 27, 2017"
output: ioslides_presentation
---
<style type="text/css">
body{ /* Normal */
font-size: 16px;
}
code.r{ /* Code block */
font-size: 4px;
}
pre {
font-size: 42px
}
</style>
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
---
### Slide with R Output
```{r echo = TRUE}
##here is some R code
1+3
##Why is the output the same size as the code?
```
我在Windows上使用Pandoc 2.0.5,rmarkdown_1.8.5和knitr_1.15.1。
编辑:这是我屏幕加载幻灯片的html:
<slide class=""><hgroup><h2></h2></hgroup><article >
<h3>Slide with R Output</h3>
<pre class = 'prettyprint lang-r'>##here is some R code
1+3</pre>
<pre >## [1] 4</pre>
<pre class = 'prettyprint lang-r'>##Why is the output the same size as the code?</pre></article></slide>
<slide class="backdrop"></slide>
</slides>
我还尝试了一种稍微不同的方法来自定义幻灯片,基于每张幻灯片,如this thread中所述。
---
title: "CSStest"
author: "Me"
date: "December 27, 2017"
output: ioslides_presentation
---
Presentation Title
========================================================
author: Jane Doe
transition: none
<style>
.small-code pre code {
font-size: 1em;
}
</style>
Slide 1 - large code
========================================================
Regular slide text here
```{r}
head(cars)
```
Slide 2 - small code
========================================================
class: small-code
More regular slide text...
```{r}
head(cars)
```
但同样,字体大小没有变化
更新:我意识到有一个较新版本的Knitr,但是使用knitr_1.17我遇到了同样的问题。