Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Markdown: Change default font size of code chunks in ioslides

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?

like image 918
Martin Schmelzer Avatar asked Apr 10 '15 14:04

Martin Schmelzer


People also ask

How do I add code chunks in markdown?

Code chunks in an R Markdown document contain your R code. All code chunks start and end with ``` – three backticks or graves.

What is Ioslides?

ioslides is one of the presentation format that can be easily put together using R Markdown. It has good compatibility with html, and very easy set-up.


1 Answers

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/

like image 146
Martin Schmelzer Avatar answered Sep 28 '22 03:09

Martin Schmelzer