R-markdown - 不同部分的字体大小不同

R-markdown - different font size in different sections

我想在 r markdown 的不同部分有不同的字体大小,这里是一个例子:

```{r psection 1}
# I would like to have font size 20
print("Hello, World!")
```


```{r psection 2}
# I would like to have font size 10
print("Hello, World!")
```

我想知道这是否可能?到目前为止,我的理解是整个文档的字体大小必须相同(headers 除外)。

一种解决方案是将您的部分包装到围栏 div 中并使用 CSS 设置部分样式。

::: {.large}
```{r psection 1}
# I would like to have font size 20
print("Hellow, World!")
```
:::


::: {.normal-size}
```{r psection 2}
# I would like to have font size 10
print("Hellow, World!")
```
:::

<style>
.normal-size pre {
  font-size: 10pt;
}
.large pre {
  font-size: 20pt;
}
</style>