A RUC (Renmin University of China) LaTex beamer template in R Markdown


In 2021, I created a post introducing a beamer template for TAMU. Nowadays, I am working at the Renmin University of China. Thus I adjusted that TAMU template to match RUC (most of the changes are color-related).

Again, all the beamer templates are originally from Dr. Steven V. Miller.

Download the RUC template

Here from my Github, you can directly download the RUC template with the RUC color and logo (RUCTemplate.tex). You can also find an example of RUC beamer presentation there (RUCBeamer.pdf).

Below I will briefly introduce the changes I made to Dr. Miller’s original template. Before you start your editing, you are recommended to quickly go over the template to have a basic idea of what’s going on there.

RUC color

To customize colors in the RUCTemplate.tex template, you can go to the code section below. I define two colors, rucmaroon and rucwhite. In the second part of the code section, you can customize colors for frame title, title, block title, etc.

% Some optional colors. Change or add as you see fit.

% Some optional color adjustments to Beamer. Change as you see fit.
\setbeamercolor{local structure}{fg=rucmaroon}
\setbeamercolor{section in toc}{fg=rucwhite,bg=rucmaroon}
\setbeamercolor{subsection in toc}{fg=rucwhite,bg=rucmaroon}
\setbeamercolor{footline}{fg=rucmaroon, bg=rucwhite}
\setbeamercolor{block title}{fg=rucwhite, bg=rucmaroon}

Other changes I made to the template

I also slightly edited the original template based on suggestions by a contributor at Stackoverflow. See the post here.

Using the template in R Markdown

The YAML header in R Markdown (RUCBeamer.Rmd) would like something below. You need to specify the path where you store the template. Here I created a folder particularly for the template. Here again I use an absolute path.

title: "RUCBeamer"
subtitle: ""
author: Yabin Da
date: "2023-04-23"
institute: \normalsize School of Agricultural Economics and Rural Development
fontsize: 10pt
    template: C:/work/RUCBeamer/RUCBeamer/RUCTemplate.tex
    keep_tex: true
    slide_level: 3
make149: true


You should set keep_tex:true, which will retain the LaTex file that actually creates your beamer slides. I found it’s very useful for troubleshooting.

How to include LaTex tables in R Markdown

At the end of this post, I want say something about how to include LaTex tables in beamer presentation in R Markdown.

There are two different types of tables: user-defined tables and regression result tables.

For the first scenario, it can be a data frame containing data or other important information that you want to present as a table in your presentation. In this case, you’d better refer to the kbl function from the kableExtra package. It has numerous features and is easy to customize based on your needs. You are highly recommended to check out this website for more detailed information.

Below I show a code example and the created table in beamer slide.

df <- read_csv('cutoff.csv')

df %>%
  kbl(booktabs = T,caption = 'Estimated temperature thresholds for each of the seasons', linesep = "") %>%
  kable_styling(full_width = F, font_size = 7) %>% 
  footnote(general = "\\\\tiny{Note: The lower threshold is restricted to be at least 5 °C above zero and 10 °C below the maximum temperature. The upper threshold is set to be at least 5 °C above the lower threshold and 5 °C below the maximum temperature. Relaxing those restrictions do not significantly change the results.}",footnote_as_chunk = T,
           threeparttable = T, escape = F,
           general_title = "")

Here I’d like to emphasize two more things. Firstly, the default font for table note is footnote. If you have a very long note, you may need change to tiny (see the footnote in the code chunk). But do REMEMBER to set the escape = F, otherwise the \\\\tiny command won’t be rendered by R Markdown.

Secondly, by default the footnote will be a list below the table. That means the word Note: will be in the row of the note. The content of the note starts at the second row. You can set footnote_as_chunk = T to fix this problem.

However, the appearance of the footnote is still wired (see the image below). Therefore, I set the general_title = "" to remove the default Note: and directly start my note with Note:.

Yabin Da
Yabin Da
Assistant Professor

Research interests include Environmental Economics (Climate Change), Applied Econometrics, and Causal Inference.