I'm creating some HTML slides using the following workflow:
.md
document created with knitr
0.8.md
file using pandoc 1.10.1This 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:
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?
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:
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With