4
votes

I want to insert a table of contents slide toward the beginning , but not the very beginning.

Additionally, I want it so that as each new section arrives, the table of contents slide is repeated, but with this time everything grayed out except the current section, for example see image.

(this other answer will not work because toc: true just puts one table of contents at the very beginning)

Some answers KIND of exist in Latex (see here), but I don't know how to operationalize these within markdown. More generally, I have trouble integrating native beamer latex into rmarkdown, so if someone can show me how to do that, esp with this example, that is helpful.

enter image description here

Beamer preamble:

output:
  beamer_presentation:
    fig_width: 7
    fig_height: 6
    fig_caption: false
#    keep_tex: true
#    toc: true
    slide_level: 3
    includes:
      in_header: ~/Google Drive/.../.../../latexbeamertheme.r
header-includes:
- \AtBeginSection[]{\begin{frame}\tableofcontents[currentsection]\end{frame}}
1
@Kristofersen it's not a duplicate, that method can be solved using toc, which i am notwolfsatthedoor

1 Answers

4
votes

You can solve this problem via header-includes; that's how you add things to what we'd call the preamble in a LaTeX document. Here's example code that generates a presentation with what I think you want to accomplish:

---
title: "Example"
output: beamer_presentation
header-includes:
- \AtBeginSection[]{\begin{frame}\tableofcontents[currentsection]\end{frame}}
---

# Test Section One

----

Test

----

Test


# Test Section Two

----

Test

----

Test

Edit:

If you want or need to do this manually, rather than using the header-includes approach, you can:

---
title: "Example"
output: beamer_presentation
---

# Test Section One

----

\tableofcontents[currentsection]

----

Test

----

Test


# Test Section Two

----

\tableofcontents[currentsection]

----

Test

----

Test