How can I show page numbers (preferably like 4/10, 5/10 etc.) on an rmarkdown beamer presentation?
4 Answers
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).

- 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
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]
---

- 41
- 4
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

- 33,336
- 5
- 41
- 62
-
-
@dearN Is your beamer version new enough? (>=v3.48) – samcarter_is_at_topanswers.xyz Jun 17 '20 at 12:22
-
How do I check (beamer version) via command line? You ask a pertinent question. – dearN Jun 17 '20 at 14:45
-
@dearN There should be a .log file in the same folder as the .tex file.This log file should include the version number – samcarter_is_at_topanswers.xyz Jun 17 '20 at 15:08
-
There is no log file... I am using `pandoc -t beamer foo.md -o foo.pdf`. – dearN Jun 17 '20 at 15:33
-
@dearN I don't know if this rmarkdown syntax with the header includes works for markdown. if yes the `keep_tex` option should make sure that the log file is also kept – samcarter_is_at_topanswers.xyz Jun 17 '20 at 15:34
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

- 16,510
- 17
- 74
- 111