Table of contents blank

Asked by At

I am trying to create a beamer presentation using R Markdown. Everything was fine until I updated the software to latest versions of R and RStudio. Now my Table of Contents do not appear (blank page instead) and the words "Section 1", "Section 2" ... etc appear above every Section title on my presentation.

I tried with toc: true, toc: false, changing theme, even creating a new R Markdown beamer from scratch but nothing worked.

title: "TITLE"
subtitle: "Subtitle"
author: "Guillermo Ortiz"
date: "9-oct-2019"
output: beamer_presentation
theme: "Madrid"
toc: TRUE

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

# Hello

## Goodbye

Bla bla bla bla

1 Answers

user2554330 On Best Solutions

I don't see all of what you describe: I get the section numbers showing, but the table of contents isn't blank. The following fixes the section number issue, but it might not fix your TOC:

The problem is in the generated .tex file. When you specify the theme to be "Madrid", R Markdown is putting the LaTeX line


into the .tex file. The problem is that it gets put in after a bunch of customizations to the style (\setbeamertemplate{section page}, etc.) and it overrides them.

[Edited to add:] this is actually how it should be. You asked for Madrid, if you want something different, you should have to ask for it. Pandoc shouldn't be overriding the theme you asked for.

There are several ways to ask for this change to the Madrid theme. One is to include the request in the header, by putting them in a file (e.g. mysections.sty) and putting this in your YAML:

      in_header: mysections.sty

The mysections.sty should contain something like this (the Pandoc default):

\setbeamertemplate{section page}{
\begin{beamercolorbox}[sep=12pt,center]{part title}
  \usebeamerfont{section title}\insertsection\par

You might want other options (e.g. \begin{beamercolorbox}[sep=12pt,center,rounded,shadowed]).