Search code examples
rlatexr-markdownbeamer

How to add page numbers on rmarkdown beamer slide under theme: "boxes"?


Using rmarkdown beamer, I try to add slide number at the bottom of each slide but keep failing. Is there anyway I can add slide number on each page under beamer theme called "boxes"?

---
title: "Big Business" 
author: |
| Mr. Bean
| Sunny College
output: 
beamer_presentation:
    theme: "boxes"
    citation_package: natbib
biblio-style: apalike 
incremental: TRUE
header-includes:
- \usepackage{makecell}
- \usepackage{booktabs}
- \usepackage{adjustbox}
---
# Motivation
Big business

# Motivation 2
Small business 

Solution

  • The boxes theme has a special syntax to add things to the footline:

     \addfootbox{normal text}{\hfill\insertframenumber\quad}
    

    (replace <normal text> with any other beamer colour you like)

    MWE:

    ---
    title: "Big Business" 
    author: |
      | Mr. Bean
      | Sunny College
    output: 
      beamer_presentation:
        theme: "boxes"
        citation_package: natbib
    biblio-style: apalike 
    incremental: TRUE
    header-includes:
      - \usepackage{makecell}
      - \usepackage{booktabs}
      - \usepackage{adjustbox}
      - \addfootbox{normal text}{\hfill\insertframenumber\quad}
    ---
    
    # Motivation
    Big business
    
    # Motivation 2
    Small business