It is straightforward to use Sweave or knitr with beamer; the only thing you need to be careful of is you have to add the fragile
option to the frames that contain verbatim code. For LyX users, make sure you use the latest version of LyX (>= 2.1.2), and then you can use the FragileFrame
environment instead of a standard Frame
environment.
- A minimal beamer example for knitr
- Rnw source: knitr-beamer.Rnw
- LyX source: knitr-beamer.lyx
- PDF output: knitr-beamer.pdf
- A simplified version of the above example:
- Rnw source: knitr-beamer2.Rnw
- An example of using full-page tikz figures in beamer slides on Stack Overflow
- A knitr source file for including linguistic notation as graphical elements in ggplot2
One note on the Rnw source for users who came before knitr 0.6 – in the past I used this in the preamble:
\ifdefined\knitrout
\renewenvironment{knitrout}{\begin{footnotesize}}{\end{footnotesize}}
\else
\fi
It will wrap the knitr output in a footnotesize
environment, but since knitr 0.6, a single global option size
will control the font size of the whole chunk, and this trick is no longer needed.
How about HTML5 slides?
You can actually also try HTML slides, which smell fancy and modern. I have a rough tutorial here.