Search code examples
latexr-markdownbeamer

R Markdown beamer with subheading aligned below main heading


Below I show a simple example of Markdown Beamer slides. I want to insert a subheading under my main heading. However, I want it to be aligned directly under my main heading, and I want the space between the two headings to be reduced.

MWE:

---
classoption: [t]
output:
  beamer_presentation:
    slide_level: 2
---

---

## Header

### Second Header

- Content

Desired Result:

enter image description here


Solution

  • The problem is that rmarkdown does not set the second header as framesubtitle, but for some reason inserts a block instead. As your beamer theme does not set the colour of blocks, you don't even get to see it ....

    Instead you can use the \framesubtitle{...} macro:

    ---
    classoption: [t]
    output:
      beamer_presentation:
        slide_level: 2
        keep_tex: true
    ---
    
    ---
    
    ## Header
    
    \framesubtitle{Second Header}
    
    - Content
    

    enter image description here