rmarkdown beamer presentation: how to not print section slides?
Asked Answered
W

1

13

I am writing a beamer presentation in rmarkdown and converting it to pdf with knitr. I want to define sections at the header1 level, e.g. # Introduction, and then have a slide titled something else e.g. ## Introducing my brilliant research. Having the header1 level define sections is nice as the names of the sections can be displayed in the slide header in certain beamer themes, and this is why I include it.

But I do not want rmarkdown to insert a slide that simply says the name of the section between sections, which at the moment it is doing. Is there a way to not print a slide with the section name between sections? I thought slide_level would control this behavior but it does not seem to (or perhaps I am using it wrong).

A minimal reproducible example of my problem can be obtained with this code:

---
title: "Test Pres"
author: "Professor Genius Researcher"
date: "24 February 2017"
output: 
  beamer_presentation:
    slide_level: 2
    theme: "Singapore"
    colortheme: "rose"
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

# Markdown Intro

## R Markdown

This is an R Markdown presentation. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.

# Using Bullets

## Slide with Bullets

- Bullet 1
- Bullet 2
- Bullet 3

# Including Chunks

## Slide with R Output

```{r cars, echo = TRUE}
summary(cars)
```

## Slide with Plot

```{r pressure}
plot(pressure)
```

At the moment, this code produces slides that say Markdown Intro, Using Bullets, and Including Chunks. I would like those slides labeling the sections omitted. Is this possible?

Wiesbaden answered 24/2, 2017 at 13:24 Comment(5)
Used slide_level: 1? Is this solving your problem?Settling
no that makes the section title the title of the slide and puts all the subsequent slides into text boxes underneath itWiesbaden
Is removing the space after the header1 not what you had in mind either?Stowell
See LaTeX Beamer prevent showing the TOC, I tried replacing # Including Chunks with \section*{Including Chunks} but latex-engine pdflatex returns an error ! Missing \endgroup inserted.Swampland
See also the Rmarkdown help on advanced PDF customization.Swampland
S
11

Create a new Latex template where you remove this part from the preamble:

\AtBeginSection[]
{
  ....
}

Place this latex template in the same folder as your .Rmd file and refer to it in the Rmd Yaml front matter using template: mytemplate.tex as explained here.

Swampland answered 24/2, 2017 at 16:38 Comment(3)
Brilliant. Many thanks indeed. One small change: the template file suggested via your link doesn't seem to cover beamer. I couldn't find the default beamer template on my system, so I got it here and did the edit as you suggested.Wiesbaden
The template link above is broken, as the default_beamer template seems to be merged to default_latex. At least, default_latex works for me.Apocryphal
Modifying YAML header with header-includes: - \AtBeginSection{} is also a viable option. Please see #38180941Roundtree

© 2022 - 2024 — McMap. All rights reserved.