Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 303
dizhihong Avatar asked May 30 '19 06:05

dizhihong


2 Answers

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;
  }
}
like image 80
Emi Avatar answered Nov 19 '22 00:11

Emi


Small addition to @Emi's answer: if you use the package xaringanthemer, you can add the code in extra_css:

```{r xaringan-themer, include=FALSE, warning=FALSE}
library(xaringanthemer)
style_mono_accent(
  base_color = "#1c5253",
  extra_css = list(
    ".has-continuation" = list(
      "display" = "block !important"
    )
  )
)
```
like image 2
bretauv Avatar answered Nov 18 '22 23:11

bretauv