Markdown: Change default font size of code chunks

2019-02-23 01:18发布

问题:

I am trying to change the font size of a code chunk (more precisely I want to use a smaller font). Take the following basic example:

---
title: "Example"
output:
  ioslides_presentation:
  toc: yes
widescreen: yes
---

## Code

```{r, eval=FALSE}
print(mtcars)
```

Anyone an idea? Is there a YAML option like code-font-size or something like that?

回答1:

You can change the default font size document wide using

<style>
pre {
  font-size: 20px;
}
</style>

which you can put right underneath your YAML header or in a seperate stylesheet (CSS file) that you can include in your YAML.

You may want to change the settings for padding and margin as well in order to prettify chunk layout.

Modify single chunks

It is possible to add a class to the code chunks you want to modify (if not all of them). Check out the answer here: stackoverflow.com/questions/37944197/