In a xaringan
presentation, the slideNumberFormat
argument is often set to %current% / %total%
. It is possible to use a specific slide number in this argument?
For instance, if I have a "final" slide like this:
---
name: mylastslide
# Thanks
with appendix slides behind, I want to display slide numbers like %current% / %mylastslide%
with %mylastslide%
the number of my slide called mylastslide
.
Thanks.
[Edit after @user2554330 suggestion]
For this code, with an incremental slide,
---
title: "Presentation Ninja"
subtitle: "⚔<br/>with xaringan"
author: "Yihui Xie"
institute: "RStudio, PBC"
date: "2016/12/12 (updated: `r Sys.Date()`)"
output:
xaringan::moon_reader:
lib_dir: libs
---
background-image: url(https://upload.wikimedia.org/wikipedia/commons/b/be/Sharingan_triple.svg)
```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
```
<script>
var slideshow = remark.create({slideNumberFormat : function (current, total) {
return 'Slide ' + current + ' of ' + (this.getSlideByName("mylastslide").getSlideIndex() + 1); },
highlightStyle: "github",
highlightLines: true,
countIncrementalSlides: false});
</script>
Image credit: [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Sharingan_triple.svg)
---
class: center, middle
# xaringan
---
hello
--
world
--
thanks
--
really
--
byebye
---
name: mylastslide
# Final slide
Install the **xaringan** package from [Github](https://github.com/yihui/xaringan):
```{r eval=FALSE, tidy=FALSE}
devtools::install_github("yihui/xaringan")
```
---
# Appendix
The last slide (ie appendix) is numbered as Slide 6 of 9
(and not Slide 6 of 5
) and 9 is the url index of mylastslide
. (I used + 1
in the slideNumberFormat
function because indexes start at 0.)
Thanks.