% use 'handout' to produce handouts %\documentclass[handout,nogin]{beamer} \documentclass[nogin]{beamer} \usepackage{graphicx} \newcommand{\vn}[1]{\mbox{{\it #1}}} \newcommand{\vb}{\vspace{\baselineskip}} \newcommand{\vh}{\vspace{.5\baselineskip}} \newcommand{\vf}{\vspace{\fill}} % I define 'mypause to be either \pause or null so I can decide % later if I want to use overlays \newcommand{\mypause}{} %\newcommand{\mypause}{\pause} % uncomment the next two lines for handouts %\usepackage{pgfpages} %\pgfpagesuselayout{4 on 1}[letterpaper, border shrink=5mm,landscape] % Boadilla has page numbers, but no navigation bar % Frankfurt has no page numbers but does have a navigation bar \usetheme{Boadilla} %\usetheme{Frankfurt} %\usepackage{beamerthemesplit} % I like to use Maroon and Gold rather than White and Blue, and % sienna for some highlighting. I define the colors myself \definecolor{maroon}{rgb}{.6902,.1882,.3765} \definecolor{sienna}{rgb}{.53,.31,.16} \definecolor{gold}{rgb}{1,.84314,.0000} \setbeamercolor{frametitle}{fg=maroon,bg=gold} \usecolortheme[named=maroon]{structure} \title{Sweave and Beamer} \author[A. Rendahl]{Sanford Weisberg, revised by Aaron Rendahl} \institute{Univ. of Minnesota} \date{January 28, 2009} \begin{document} % If you don't like section header slides, comment out the following %\AtBeginSection[]{% %\begin{frame} %\frametitle{Outline} %\tableofcontents[currentsection] %\end{frame} %} % End for section header slides \frame{\titlepage} % Comment out if you don't want a table on contents slide %\frame{\tableofcontents} \section{Text only} \begin{frame}[containsverbatim] \frametitle{Text} Here is an example with just output. To show input and output, set echo to TRUE. <>= options(width=55,show.signif.starts=FALSE) library(alr3) data(forbes) m1 <- lm(Lpres~Temp,forbes) summary(m1)$coef @ \end{frame} \begin{frame} \frametitle{Using xtable} The \texttt{xtable} package outputs data in \LaTeX\ format: <>= library(xtable) xtable(summary(m1)$coef) @ \end{frame} \begin{frame}[containsverbatim] \frametitle{Draw a graph automatically} A file called \texttt{mystuff1-one.pdf} will be created, where \texttt{mystuff1.Rnw} is the name of the file. <>= plot(Lpres~Temp,forbes) abline(m1) @ \end{frame} \begin{frame} \frametitle{One way to resize a graph:} Use \texttt{include=FALSE} and then include it manually. <>= plot(Lpres~Temp,forbes) abline(m1) @ \vspace{-.5in} \includegraphics[width=\textwidth]{mystuff1-two.pdf} \end{frame} \begin{frame} \frametitle{Another way to resize a graph} Use the \texttt{nogin} option in your documentclass statement, then set \texttt{height} and \texttt{width} in the Sweave call. Without \texttt{nogin}, the width is always 80\%; without, it is set to the figure width. \bigskip \begin{columns} \column{0.5\textwidth} <>= par(mar=c(5,4,0,0)+0.1, cex=0.7) plot(Lpres~Temp,forbes) abline(m1) @ \column{0.5\textwidth} Both can be used together to get both the text size proportional to the figure and the absolute text size just the way you want it. Setting the margin and sizing parameters with \texttt{mar} and \texttt{cex} in \texttt{R} before plotting can also help. \end{columns} \end{frame} \end{document}