Search code examples
rr-markdownxaringan

Get Xaringan incremental animations to print to PDF?


My Xaringan (fantastic package) deck in HTML has incremental additions of bullets that behave as desired.

When printed to PDF, the incremental additions disappear.

I tried printing the HTML to PDF in a few ways suggested by the documentation: webshot(), pagedown::chrome_print(), and from Chrome browser by hand. All produce the same PDF with no incremental additions.

A simple example:

---
title: "No incremental in PDF"
output: 
  xaringan::moon_reader:
    css: ['default', 'metropolis', 'metropolis-fonts', 'bootcamp.css']
---

# Testing incremental bullets

- Bullet 1
--

- Bullet 2
--

- Bullet 3

The bullets appear on successive slides in the HTML, as desired. But all three appear at once the second page after printing to PDF. That second page with all bullets is numbered "4/4" on the slide...but there are no 2/4 or 3/4 slides preceding it. Thanks.

R 3.6.0 RStudio 1.2.1335 xaringan 0.10.1 pagedown 0.2.6 webshot 0.5.1 Chrome 74.0.3729.169


Solution

  • When you're on an incremental slide then the class has-continuation is added to it and the corresponding print is set to display:none. To print out the incremental slides you need to overwrite this behaviour by inserting below to your css file:

    @media print {
      .has-continuation {
        display: block !important;
      }
    }