How can I insert page number to rmarkdown beamer slides?

11.1k views Asked by At

How can I show page numbers (preferably like 4/10, 5/10 etc.) on an rmarkdown beamer presentation?

4

There are 4 answers

5
civilstat On BEST ANSWER

In the front matter of the document, you can include a .tex file with extra commands as shown in RStudio's documentation here.

I created a new .tex file that I called "header_pagenrs.tex" which only includes the top 2 lines from @user4281727's answer:

\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}[page number]

Then I referenced this file at the top of my .Rmd file:

---
title: "Things and Stuff"
author: "Me"
output:
  beamer_presentation:
    includes:
      in_header: header_pagenrs.tex
---

If this still gives you errors, you might also be missing some required TeX packages (a separate problem from RStudio and rmarkdown).

0
user4281727 On

Try to put the lines below into the template

\setbeamertemplate{navigation symbols}{}

\setbeamertemplate{footline}[page number]

~/Library/R/3.1/library/rmarkdown/rmd/beamer/default.tex
0
Steve K On

Here's another option that worked for me. Didn't need to add a .tex file to my folder. Just included the following (based on above code from @civilstat) at the top of my Markdown doc.

---
title: 'Your Title'
author: "Your Name"
date: "July 4, 1776"
output:
  beamer_presentation(keep_tex = TRUE): default

header-includes:

- \setbeamertemplate{navigation symbols}{}
- \setbeamertemplate{footline}[page number]
---
6
samcarter_is_at_topanswers.xyz On

If your beamer version is reasonable up to date (>= v3.48), you can adjust the format of the frame numbers while keeping the footline of your chosen beamer theme unchanged otherwise.

---
output: 
  beamer_presentation:
    theme: "Berlin"
    keep_tex: true
header-includes:
  - \setbeamertemplate{page number in head/foot}[totalframenumber]
---

test

enter image description here