# Custom Beamer Template

Click to enlarge

Beamer is a document class that is by far the most practical tool for making presentations involving data science, business analytics, or general research. It is widely used in most conferences and easily lends itself to data intensive reporting and repetitive batch processing.

A custom beamer template is presented that is easy to extend or modify.  The benefits of the beamer document are numerous:

• Data and code objects are integrated directly into presentation and reporting objects,
• Costly copy-paste routines are eliminated whenever data or models change,
• Team collaboration can be enhanced through object sharing,
• Reproducible research is achieved since reported results are packaged with supporting data and models.

Switching from PowerPoint is justified when productivity and quality control increase.  A complete user guide for coding custom beamer documents is here. Lessons learned are shown below.

#### R integration Unlike  and R, Sweave is not extensive or complicated.

The basic Sweave syntax consists of a simple << >>= marker indicating that we want to insert and begin an R code section, followed by one or more R commands, followed by a @ marker indicating you are done writing R commands and wish to switch back to the document. The syntax is extremely simple.  The only practical twist is the ability to put option commands inside the opening marker.

In the example below, the document and Sweave concordance is started.  The first R command is to source an R script from the hard-drive for all data management and analysis. Sweave options launch the R code with console results or echoes turned off. This prevents unwanted script results or error messages from migrating into the  document.   Code sourced by the document runs in a unique environment so presentation data does not mask or corrupt analysis data already present in R.

#### Bullet Slides

Click to enlarge

Bulleted slides can include itemized and enumerated lists, as shown.  The preamble has already formatted bullet colors, font type and size.  Meanwhile, the slide presents bullets in two columns.  The colored info-lines at the base of the slide are also formatted in the preamble and all text is controlled by the fields for the title page. Finally, navigation icons and advanced PDF functionality are present (e.g. see the marks along the bottom right edge of the slide).  Navigation icons are turned off by inserting \setbeamertemplate{navigation symbols}{} in the preamble.

#### R Data Tables

Click to enlarge

If Sweave allows R to be run from a document, the R package Stargazer creates code from within R.  In more basic terms, Stargazer wraps R data objects with code for pretty table formats, eliminating  formatting, data alignment and table layout hassles.  In this example, a chunk of R code is executed to generate the table and the R print function layers in additional table formats, including table size or scale.  The document will automatically update table labels and numbering.

#### R Graphics

Click to enlarge

The ability to generate R graphics inside the beamer template is equally simple: a pre-existing graphic file is loaded directly (the approach used here), or the R graphics code is run directly from the document.  Image placement, sizing and labeling remain flexible.

Click to enlarge

The custom template also has predefined text boxes, including  theoremcorolary and proof.  Each of these have fixed or predefined titles and are pre formatted environments defined in the preamble.  The theorem text box environment is shown in the example. Default settings used here include rounded corners.  Rounded corners with no shadows is achieved with [shadow=false] in the preamble.

The template also has a generalized text box that offers complete control over titles and body text using the command sequence \begin{block}{title of block} Some text… \end{block}.  Finally, the package fancybox provides basic text box highlighting using \doublebox{}, \ovalbox{}, \Ovalbox and \shadowbox{}.

#### Floating Text

Click to enlarge

The final slide in our custom template illustrates floating text, which is useful for footnotes or other ad-hoc needs.  The package textpos is used in the preamble to define a reference environment for footnotes (see lines 32 to 34).  The environment defines font type, size and color, and the environment is activated as needed using a simple function call.  The environment requires two input arguments, the x and y coordinates where text will land on the page.  A beamer slide has dimensions 128mm by 98mm with slide coordinates starting in the upper left-hand corner.  Trial and error will ensure ad-hoc text lands where you want.

This entry was posted in LaTeX, Misc Tricks, R Programming. Bookmark the permalink.