user1700890
user1700890

Reputation: 7730

R-markdown - different font size in different sections

I would like to have different font size in different sections of r markdown, here is an example:

```{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!")
```

I wonder if this is possible? So far my understanding that font size must state the same for whole document (except headers).

Upvotes: 2

Views: 267

Answers (1)

tarleb
tarleb

Reputation: 22599

One solution would be to wrap your sections into fenced divs and to use CSS to style the sections.

::: {.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>

Upvotes: 1

Related Questions