Add beamer frame options in knitr/rmarkdown
Asked Answered
D

2

17

I'm trying to add frame numbers to my Beamer presentation written in rmarkdown. However, I would like to suppress the numbers on the title page using the \begin{frame}[plain] option (from the second answer here: https://tex.stackexchange.com/questions/82794/removing-page-number-from-title-frame-without-changing-the-theme). However, when compiling from rmarkdown to tex, the \titlepage already creates a frame environment, so in effect I get a double frame and thus an error.

So when compiling this:

---
output:
  beamer_presentation:
    includes:
      in_header: header.tex
---

\begin{frame}[plain]
\titlepage
\end{frame}

I get this in latex:

\begin{frame{

  \begin{frame}
     \titlepage
  \end{frame}

\end{frame}

In the header.tex I have this:

\let\otp\titlepage
\renewcommand{\titlepage}{\otp\addtocounter{framenumber}{-1}}

So my workaround now is to just use a plain \maketitle in rmarkdown, then compile to .tex, add the [plain] option, then compile to pdf. However, I would like to avoid that intermediate step. Is this possible in rmarkdown?

Denson answered 20/2, 2015 at 8:58 Comment(0)
P
10

rmarkdown uses pandoc to convert a Rmd file to a pdf via beamer/latex. pandoc uses templates to control how the conversion goes.

One way to deal with your problem is to :

  1. Download the default beamer template rmarkdown uses and open it.

  2. Change line 137 from this :

    \frame{\titlepage}
    

    To this :

    \frame[plain]{\titlepage} 
    
  3. Add the path to your modified template in your Rmd file :

    ---
    output:
      beamer_presentation:
        includes:
          in_header: header.tex
        template:/path/to/new/template.tex
    ---
    

Note that you need to specify the whole path, or store the template where pandoc can find it (~/.pandoc/templates on a linux machine)

Pinchhit answered 29/4, 2015 at 17:20 Comment(0)
E
9

Add {.plain} after the title as in:

----

# I'm the title {.plain}

Source: Pandoc User’s Guide

Encounter answered 15/11, 2017 at 14:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.