Search code examples
quarto

Is it possible to exclude appendix slides of the total number of slides?


In the example below, I have 3 slides: main content, appendix title and appendix content. However, I'd like to exclude the two appendix slides from the total count on the bottom right.

The expected output is to have 1/1 on the bottom right. How can I do that?

---
format: 
  revealjs:
    slide-number: true
---

Slide with main content

# Appendix {.appendix}

---

Slide with appendix content

enter image description here


Solution

  • Resolved here: the solution is to write a Lua filter to automatically apply visibility="uncounted" to all slides in the "Appendix" section.

    custom.lua

    local in_appendix = false
    
    Header = function(h)
      if h.level == 1 then
        if h.classes:includes("appendix") then
          in_appendix = true
          h.attributes["visibility"] = "uncounted"
        else
          in_appendix = false
        end
      end
      if h.level == 2 and in_appendix then
        h.attributes["visibility"] = "uncounted"
      end
      return h
    end
    
    ---
    format: 
      revealjs:
        slide-number: true
        filters: [custom.lua]
    ---
    
    Slide with main content
    
    # Appendix {.appendix}
    
    ##
    
    Slide with appendix content
    
    ##
    
    Another slide with appendix content
    

    enter image description here