1
votes

I am trying to create my first set of slides using RMarkdown beamer.

What I have so far:

---
title: title
author: author
date: date
output: beamer_presentation: default
ioslides_presentation: default
linkcolor: blue
---
    
## Plan for today
    
text
        
## Outline
    
text
    
## Day 1
    
text
    
## Day 2
    
text
    
## Day 3
    
text
    
## Day 4
    
text
    
## Day 5
    
text

I have seen presentations with the Table of Contents at the top in the header and when the presenter changes to a new slide with a different section, it highlights the section in the header where the presenter is. What's the piece of code I need in order to do this? Ideally I want in the Table of Contents 'Plan for today' and 'Outline' under Introduction, and then Day 1, Day2, etc. up to Conclusion.

I also want to:

  1. add a picture to the header at the top right corner
  2. add page number in the footer at the bottom right corner like 3/14 (only after the title page)

Any thoughts? Many thanks in advance.

A picture of what I am trying to do: enter image description here

1

1 Answers

0
votes

For a TOC in the header, it's best to choose among predefined themes which support this, e.g., Szeged, and then specify it in the YAML with theme: Szeged.

To get the desired outline you need to use the right combination of first-level (starting with #) and second-level (starting with ##) section headers, see below. I also set slide_level: 3.

Adding a logo to the top right, page numbers to the footer and a custom title slide requires some LaTeX code that needs to be inserted in the template used to compile the final PDF output. You can do this by including code in a separate .tex file using the includes option in the YAML header of the .Rmd file. It should look like this:

presentation.Rmd

---
output:
  beamer_presentation:
    theme: Szeged
    slide_level: 3
    includes:
      in_header: header.tex
---

# Introduction

## Plan for today
text

## Outline
text

# Day 1

text

# Day 2

and so on ...

# Conclusion

your conclusion

header.tex

% add custom title slide
\setbeamertemplate{title page}{
  \inserttitle\\[0.5ex] 
  \insertauthor\\[0.5ex] 
  \insertdate
  \pagenumbering{gobble}
  \thispagestyle{plain}
}
% remove title slides at beginning of sections
\AtBeginSection{}
\AtBeginSubsection{}
% add page counter to the footer
\setbeamertemplate{footline}[frame number]
\setbeamertemplate{frametitle}{}
% add logo
\usepackage{textpos}
\addtobeamertemplate{frametitle}{}{%
\begin{textblock*}{100mm}(0.9\textwidth,0.5cm)
 \includegraphics[height=0.5cm,width=1cm]{logo}
\end{textblock*}}

The logo is a .PNG file from here. For your image to be displayed nicely you'll likely need to make some adjustments to positioning and size. Note that header.tex and logo.png need to be in the same directory as presentation.Rmd.