Midoux
Midoux

Reputation: 73

Custom Footer on the Title Slide for Quarto revealjs Slides

I use quarto to make my slides with revealjs and a template.

I'm looking for a simple way to define a different footer on the title-slide.

Currently my footer is simply defined with :

---
title: "My Title"
author:
  - name: "John Doe"
date: "2023-06-30"
date-format: long
format: inrae-revealjs
draft: true
footer: "My global footer"
license: "CC BY-SA"
bibliography: references.bib
---

I want to display the document licence on the title-slide. I was thinking of using the footer for this. However, I can't manage to edit the title-slide footer only.

If not, do you know a simple way of displaying the licence on the document?

Thanks in advance

Upvotes: 3

Views: 1852

Answers (1)

Shafee
Shafee

Reputation: 20107

At first, I don't think the license yaml does anything in case of revealjs format, since it is not enlisted here.

Now to use a custom footer for title slides, you can make use of title-slide-attributes yaml key and use a data attribute like data-footer: <A custom footer for title slide> under the title-slide-attributes.

And then using javascript you can write the logics for handling that data-footer so that the custom footer text is shown only in the case of title slide.

add-custom-footer.html

<script type="text/javascript" charset="utf-8">
  function add_custom_footer() {
    let title_slide = document.querySelector("section#title-slide");
    let title_slide_footer = title_slide.getAttribute('data-footer');
    let footer = document.querySelector('div.footer p');
    let global_footer_text = footer.innerHTML;
    
    if (title_slide.classList.contains('present')) {
      footer.innerHTML = title_slide_footer;
    }
    
    Reveal.on( 'slidechanged' , event => {
        if (event.currentSlide.matches('#title-slide')) {
          footer.innerHTML = title_slide_footer;
        } else {
          footer.innerHTML = global_footer_text;
        }
      });
  };
  
  window.addEventListener("load", (event) => {
    add_custom_footer();
  });
</script>

presentation.qmd

---
title: "My Title"
author:
  - name: "John Doe"
date: "2023-06-30"
date-format: long
format: inrae-revealjs
draft: true
footer: "My global footer"
bibliography: references.bib
title-slide-attributes: 
  data-footer: "CC BY-SA"
include-after-body: add-custom-footer.html
---

## 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
```


title slide

next slide after the title slide

Upvotes: 3

Related Questions