18

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

ilker_arslan
  • 637
  • 3
  • 7
  • 17

4 Answers4

20

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).

civilstat
  • 416
  • 5
  • 9
  • Is it possible to remove the page number from the title page? – mharinga Feb 07 '18 at 16:39
  • I'm afraid I don't know how! – civilstat Feb 07 '18 at 21:37
  • @civilstat I have been using this script for well over a year now, but today it is failing... MAC OSX 10.13.6, R 3.5.2 RStudio 1.1.463. To clarify: same exact document, just recompiling. Now no page number outputs... the `header_pagenrs.tex` file seems to be causing the `include: ... theme:` output to malfunction as well – alexwhitworth Jan 09 '19 at 19:21
  • After updating all LaTeX packages, this is largely resolved. The theme I was using ("Malmoe") still has problems; but a switch to a new theme resolves. – alexwhitworth Jan 10 '19 at 19:33
  • Glad to hear that updating packages helped. Unfortunately I have no ideas about how to fix the issue with your original theme. – civilstat Jan 11 '19 at 20:48
4

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]
---
Steve K
  • 41
  • 4
2

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

0

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
Christian Gollhardt
  • 16,510
  • 17
  • 74
  • 111