Search code examples
quartoreveal.js

Repeat title slide at end of reveal.js presentation and add additionnal slides after


I'd like to repeat my title slide at the end of my quarto reveal.js presentation.

I'm looking for a command like title-slide or something other. I'm also trying to add after this title-slide some additionnal slides {visibility="uncounted"} like this. These additionnal slides are as appendix.

Thanks


Solution

  • This is a follow-up answer to the question asked here.

    So create a blank slide as a placeholder for the repeated title slide with class .placeholder-for-titleSlide and title-slide will be copied here. If you want to the repeated title slide to be uncounted use visibility="uncounted" on the placeholder slide.

    ---
    title: "Title Slide"
    subtitle: "Its a subtitle"
    author: None
    date: last-modified
    format: 
      revealjs:
        include-in-header: append-title-slide.html
    slide-number: true
    ---
    
    ## Quarto
    
    Quarto enables you to weave together content and executable code into a finished presentation. To learn more about Quarto presentations see <https://quarto.org/docs/presentations/>.
    
    ## Bullets
    
    When you click the **Render** button a document will be generated that includes:
    
    -   Content authored with markdown
    -   Output from executable code
    
    ## Code
    
    When you click the **Render** button a presentation will be generated that includes both content and the output of embedded code. You can embed code like this:
    
    ```{r}
    1 + 1
    ```
    
    
    ## {.placeholder-for-titleSlide visibility="uncounted"}
    
    
    ## Additional Slide 01 {visibility="uncounted"}
    
    Some additional stuff
    
    
    ## Additional Slide 02 {visibility="uncounted"}
    
    Some more additional stuff
    

    append-title-slide.html

    <script>
      function move_titleSlide() {
          var titleSlide = document.querySelector('section#title-slide');
          var titleSlideClone = titleSlide.cloneNode(true);
          titleSlideClone.id = 'title-slide-cloned';
          var placeholder = document.querySelector('section.placeholder-for-titleSlide');
          var visibility = placeholder.getAttribute('data-visibility');
          if (visibility !== null) {
            titleSlideClone.setAttribute('data-visibility', visibility);
          }
          placeholder.replaceWith(titleSlideClone);
          Reveal.sync();
      }
    
      window.document.addEventListener("DOMContentLoaded", function (event) {
        move_titleSlide();
      });
    </script>
    
    
    <style>
      #title-slide-cloned {
        text-align: center
      }
    
      #title-slide-cloned .subtitle {
        margin-bottom: 2.5rem
      }
    </style>