Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add beamer frame options in knitr/rmarkdown

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?

like image 441
user2987808 Avatar asked Feb 20 '15 08:02

user2987808


Video Answer


1 Answers

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)

like image 77
scoa Avatar answered Sep 29 '22 11:09

scoa