Martin Dabbel Ju Smelter Martin Dabbel Ju Smelter - 2 months ago 76
Markdown Question

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"
toc: yes
widescreen: yes

## Code

```{r, eval=FALSE}

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


Ok I digged through the default.cssof ioslides (on Mac its deep inside the R.framework). Make a copy and place that copy where you want and import it in the YAML header of your RMarkdown script. Now in line 529 you can find

pre {
  font-family: 'Source Code Pro', 'Courier New', monospace;
  font-size: 20px;
  line-height: 28px;
  padding: 10px 0 10px 60px;
  letter-spacing: -1px;
  margin-bottom: 20px;
  width: 106%;
  left: -60px;
  position: relative;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  /*overflow: hidden;*/

Editing the font-size will change the default code chunk font size. But you have t0 play with the padding and margin tags in order to prettify the space between the code.

EDIT 1: If you use the .smallerargument for your slide, the default font-size will be overwritten (of course).


It is possible to add a class to the code chunks you want to modify (if not all of them). Check out the answet here:

all you have to do is to include your own CSS class like

  .myChunks {