Beamer Markdown



Beamer

Congressman Rick Astley makes another pledge on the campaign trail

Beamer Markdown Template

I’ll keep the introduction to this post fairly simple. It’s back-to-school season for professors, which means it’s time to prepare syllabi and lectures for the coming school year. I realized as I was doing some website maintenance that I never formally introduced the most common R Markdown template that I use: my Beamer template. Over four years ago, I talked a little about why people should move from Beamer to R Markdown and use the latter as a wrapper for the former. However, I’ve tweaked my Beamer templates so much since that I should probably describe it more in detail.

  1. To create a Beamer presentation from R Markdown you specify the beamerpresentation output format in the front-matter of your document. You can create a slide show broken up into sections by using the # and ## heading tags (you can also create a new slide without a header using a horizontal rule (-).
  2. Beamer presentation. Mtheme (and/or a local variant I called In this section, we discuss how to add figures and tables into your rmarkdown document, and how to provide captions for them. Theme: Beamer theme (e.g. Where convert is a component of imagemagick; you can probably rely on Pandoc’s Markdown Set render options with YAML When you.

The main part of slides is written in markdown, while the setting part is still completed by latex. After the markdown part is converted from pandoc to latex, it is called by latex. For example, I needed to make slides the other day. I need the following documents. R Markdown Templates For Chinese Users rmarkdown chinese rmarkdown-article-template rmarkdown-templates rmarkdown-beamer Updated May 17, 2019.

Consider this another installment in my catalog of posts on R Markdown, complementing my suite of templates for things like academic manuscripts, CVs, syllabi, Xaringan presentations, and memos (among other templates). You can also skip this and head straight to my Github repo for all these things.

Getting Started with the YAML

Here is what the YAML will resemble for my standard Beamer presentation.

Long-time users of my templates or R Markdown should recognize a fair bit here. Make title: the topic of your presentation. subtitle: is optional, but try to use it since it looks nice and fleshes out the title page. The author: field should be who you are (or me, you’re free to make everything about and by me). The institute: field should be your department or employer.

Beamer Rmarkdown Page Numbers

The titlegraphic: field should be a relative(-ish) path to a brand marker for your university or employer. LaTeX (as far as I know) is a bit wonky about paths. My template specifies this field like this, if you wanted to see what it looks like under the proverbial hood.

Thus, start a relative(-ish) path to your university’s “brand” marker, wherever it is on your hard drive. If you’re a new student trying to figure this stuff out for the first time and are unaware what I mean by “brand” in the context of universities: trust me; your university has a brand “guideline” and has copious guides to “protecting” the “brand.” Your university speaks of itself like a corporation and would hire two dozen Darren Rovells to “protect” and “promote” the “brand” if they haven’t already. Don’t believe me? Here’s my beloved alma mater trying to file a trademark for the most common word in the English language to protect its “brand” by arguing the most common word in the English language is actually its intellectual property.

Just search “brand” on your university’s website and you should be good to go from there. For what it’s worth, the titlegraphic: field is optional. You can omit this if you’d like, but then you should make the institute: field your university or employer.

The stuff under output: is worth belaboring a little bit. template: should obviously be where the actual .tex template is and keep_tex: is optional if you want to keep or discard the intermediate .tex file for the Beamer presentation. Thereafter, you can use the latex_engine: option to favor xelatex (as I do now) over pdflatex (which I used to use back when I first created my template). The only real reason for this switch is if you wanted to customize the font options (more on that later). If you set latex_engine: xelatex, you should also set dev: cairo_pdf. This will allow you to use some fancy fonts in your ggplot graphs.

Latex Beamer Markdown

As a final little note on the stuff under output:, I typically set slide_level: 3 so that three pound signs (###) denote a new slide. Two pound signs are a subsection and one pound sign is a section.

The final set of options are stuff I’ve added over the years. Most computer screens these days are widescreen, even the computers you’ll find in your class room. I want to leverage this space as well as I can. Thus, I created a make149: option so my presentations can have a 14:9 aspect ratio. This is optional. Commented out, the presentation would be the default aspect ratio for a Beamer presentation. I’m pretty sure that’s 4:3.

Finally, if you’ve set latex_engine: xelatex, why not give yourself some fonts of choice? My main font (mainfont:) is Open Sans while the title fonts (titlefont:, for slides and the title page) is Titillium Web. You may recognize these fonts on my website as well. For as much as I just riffed on universities being snobby about their “brand”, I suppose I have mine as well.

Add Your Own Colors to the .tex File

Assuming you don’t want your presentations to be orange and purple ahem, “Clemson Orange” and “Regalia”, head over to the .tex file and find the stretch of code you see below.

Change or add anything you see fit for your purposes. I always found hex color codes to be intuitive, so that’s how I enter them.

You may also want to change the colors for your frame titles and the like. Those are options are listed below.

I’m of the mentality that most Beamer presentations waste precious space with things like overhead or side navigation panels. It’s why omit those things entirely, even the navigation symbols (i.e. the tribal arm band tattoo of Beamer presentations).1 It’s more important to make the presentation informative than, well, gaudy. Yeah, I’m especially looking at you, Palo Alto. However, I do have a subtle cosmetic touch at the footline that has some of these colors. Go a bit further down until you find this stretch of code and change the Clemson color codes you see.

There are some other final color options here you may want to change if you want to de-Clemson your presentation.

Beamer

A Sample R Markdown Slide

Of course, no sample R Markdown Beamer presentation of mine is complete without weirdness. My sample presentation (which shows what the finished product looks like) riffs on using pop culture inanities as illustrations of political science concepts, so here’s “Rickrolling” toward an illustration of median voter theorem.

Beamer Markdown 3

Markdown to beamer

Beamer Markdown For Code

We can visualize median voter theorem accordingly, which pits Congressman Astley’s campaign pledges against a hypothetical rival on the distribution of preferences for emotional support.

Beamer Markdown Code

According to this graph, Congressman Astley comfortably secures re-election against his rival because his policy package of emotional support is closer to the median voter.

R Markdown Beamer Chinese

Replication, and Such

You can find the files to reproduce this presentation here on my Github. The template is here. The R Markdown file of the sample presentation is here and this PDF shows what the finished product looks like.

  1. Listen; I get it. You’ve been to Cabo, but you didn’t need to get that to show everyone you made that trip. In fact, stop showing that thing to me. I didn’t ask to see it in the first place. ↩





Comments are closed.