'Insert the number of slides up to a final slide in a rmarkdown::beamer_presentation
In a beamer presentation generated with rmarkdown::beamer_presentation
, I currently have \insertframenumber/\inserttotalframenumber
which shows the current page and the total number of slides in the presentation.
How to insert the number of slides up to a "final slide" in the footer instead of the overall "total number of slides"?
Note: I would like to refrain from having to add {.noframenumbering}
to all slides in the appendix.
MWE
Preamble.tex
\setbeamertemplate{footline}{
\leavevmode%
\hfill
\hyperlinkappendixstart{\insertframenumber/\inserttotalframenumber}
}
Presentation.Rmd
---
title: "Slide counter ends at specific slide"
output:
bookdown::pdf_book:
base_format: rmarkdown::beamer_presentation
latex_engine: lualatex
toc: false
slide_level: 2
header-includes:
- \input{files_beamer/preamble}
---
## Slide 1
## Slide 2
## Slide Final
==> count up to this slide
``` {=latex}
\insertframeendpage
```
## Additional Slide 1 (not counted)
## Additional Slide 2 (not counted)
Solution 1:[1]
If your beamer version is up-to-date, you can use the \setbeamertemplate{page number in head/foot}[appendixframenumber]
template. No need for additional packages.
---
title: "Slide counter ends at specific slide"
output:
bookdown::pdf_book:
base_format: rmarkdown::beamer_presentation
latex_engine: lualatex
toc: false
slide_level: 2
keep_tex: true
header-includes: |
\makeatletter\beamer@ignorenonframefalse\makeatother
\setbeamertemplate{page number in head/foot}[appendixframenumber]
\setbeamertemplate{footline}{%
\leavevmode%
\hfill
\hyperlinkappendixstart{%
\usebeamertemplate{page number in head/foot}%
}
}
---
## Slide 1
## Slide 2
## Slide Final
==> count up to this slide
``` {=latex}
\end{frame}
\appendix
\begin{frame}
\frametitle{Additional Slide 1 (not counted)}
```
## Additional Slide 2 (not counted)
Solution 2:[2]
Just add to the YAML-header:
header-includes:
- \usepackage{appendixnumberbeamer}
(See this SO post).
Alternatively one could likely define a new command using something like \inserttotalframenumber - \insertappendixframenumber
somewhere before \setbeamertemplate{footline}{...}
.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | mavericks |