Search code examples
rr-markdownpandocreveal.js

Including a footer an every slide with Rmarkdown and revealjs


My company requires all internal+external presentations to use an approved footer for every slide, which pushes everyone to copy and paste things into PowerPoint.

However, I would love to use R notebooks to make revealjs_presentation slide decks. Could anyone provide a simple example of a Rmarkdown notebook (or pandoc template?) I could modify that does this?

I imagine this would be useful for a lot of people at a lot of companies.


Solution

  • It's possible to add a fixed footer on all slides using the includes parameter/argument in revealjs::revealjs_presentation. (With much thanks to the earlier commenters for their suggestions which made me think of this).

    For example, I wanted to add a corporate logo and a disclaimer footer to each slide. I created a HTML file to be included before the document body with the following contents:

    <div id="header-footer">
      <img class="slide-logo" src="corporate-logo.png"/>
      <p class="slide-footer">Corporate disclaimer</p>
    </div>
    

    I then included this snippet before the body of the document with the includes parameter in the YAML header of my R markdown document (Rmd file):

    output: 
      revealjs::revealjs_presentation:
        css: styles.css
        includes:
          in_header: header.html
    

    Then, to position the logo in the top right and have the footer fixed at the bottom of each slide, I used the following CSS (stored in styles.css):

    /********** Customise logo, and footer disclaimer **********/
    /* Position the corporate logo in the top right of the page */
    #header-footer .slide-logo {
      position: absolute;
      top: 15px;
      right: 50px;
      height: 60px;
      width: 150px;
    }
    
    
    /* Style/position the footer text */
    #header-footer .slide-footer {
        position: fixed; 
        bottom: 0;
        left: 0;
        right: 0;
        height: 10px;
        text-align: center;
        font-size: 65%;
    }
    

    Of course, you can play with the CSS to style it how you would like.

    One restriction is that this places the logo and footer on every slide, including the title (but except for slides with a whole-slide background image, which hides the disclaimer and logo). I'm currently trying to figure out a way to restrict logo/disclaimer for certain slides.

    I have yet to do it, but it should be possible to wrap this up in to a custom template to integrate directly with new RMarkdown documents for your organisation, e.g. see chapters 17 and 18 for doing that in the RMarkdown book.

    I hope this is still of some use to you/others.