Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change font size in HTML5 slides prepared with markdown -> pandoc

I'm creating some HTML slides using the following workflow:

  • Code is written in R Studio editor 0.97.248
  • .md document created with knitr 0.8
  • HTML5 slides created from .md file using pandoc 1.10.1

This is the workflow described by Yihui Xie here; it's the most straightforward way I'm aware of to make slides for presentations using Markdown.

My problem is even a relatively short line of code (50 characters) runs off the right-hand side of the slide, because the default code font is large and widely-spaced.

For instance, the following slide

# Title of the slide
And some text.

````{r plotChunk, message=FALSE, fig.height=5, fig.width=5}
require(ggplot2)
ggplot(mpg, aes(x=displ, y=cty, colour=class)) + geom_point()
````

produces the following slide:

enter image description here

I could use code options tidy=FALSE to manually split lines of code, but I will never be able to fit much code on a line. Is there any way to make the default body font & code font smaller in the HTML document?

like image 532
Drew Steen Avatar asked Feb 04 '13 05:02

Drew Steen


1 Answers

Both @Yihui and @Ramnath offer effective solutions to my problem. Since each opted to respond in comments, I'll just note that I found slidify to be a quicker solution to my underlying problem, which was that I needed to modify default pandoc formatting to make pretty slides. Compare the pandoc-created slide above with the same slide created with slidify below:

enter image description here

slidify picks a more appropriate code size by default.

One reason for my trouble with pandoc may be system-specific (am running Mac OSX 10.7.5, R 2.15.1, R Studio 0.97.248, pandoc 1.10.1). Pandoc's file conversion does not seem to be quite right on my system: on the figure in the question, see how the name of the chunk is printed over the plot, rather than below the plot. When I convert Yihui's slides from his .Rmd source I get different (worse) output than he did. Note the 'html' text below, which apparently is carry-over from a previous slide in which one line of text ran off the right-hand side of the screen.

enter image description here

Finally, the fig.height and fig.width options work as expected in slidify, whereas pandoc seems to re-size figures to fill the slide. Note the crappy resolution of the plot in the question - it was a small plot, and pandoc has blown it up.

I suspect pandoc will be useful for creating documents in multiple formats from RMarkdown, but for making quick slides on my system, slidify seems like a better solution out of the box.

like image 97
Drew Steen Avatar answered Oct 12 '22 13:10

Drew Steen