Can I render a .html and a .pdf presentation in the same .qmd?
Asked Answered
C

3

5

I have been working with Quarto in RStudio to do some presentations.

I like to do the presentations with revealjs and than convert the .html output to .pdf to send to my students.

Can I render both formats at the same time?


---
title: "R and RStudio"
author: "RTheodoro"
institute: "USP"
format: 
   revealjs:
     logo: img/usp_logo.png
     slide-number: true
     show-slide-number: all
     preview-links: auto
     width: 1280
     height: 720
     theme: default
editor: visual
execute:
  echo: true
---

## What is R?

-   R is.....

Chirm answered 23/8, 2022 at 17:46 Comment(0)
P
4

You may want to try the {renderthis} package to print the html output as pdf of your quarto slides which will preserve the slide format and styles.


quarto_render.qmd

---
title: "R and RStudio"
author: "RTheodoro"
institute: "USP"
format: 
   revealjs:
     # logo: img/usp_logo.png
     slide-number: true
     show-slide-number: all
     preview-links: auto
     width: 1280
     height: 720
     theme: default
execute:
  echo: true
---

## What is R?

-   R is.....

## 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/>.

Then simply render this quarto_render.qmd file as you do, by clicking the render button in Rstudio, which will create an html file quarto_render.html in your working directory. Then from the console, run this command,

renderthis::to_pdf("quarto_render.html")

Which will create a pdf file quarto_render.pdf with slide format in your working directory.

Perchloride answered 28/8, 2022 at 2:38 Comment(1)
Thank you, renderthis looks awesome, it converts to a wide variety of types.Windhoek
P
2

I just did this and pressed "Render" in RStudio and it generated the pdf and the html. Is that what you mean?

---
title: "R and RStudio"
author: "RTheodoro"
institute: "USP"
format: 
  revealjs:
     logo: img/usp_logo.png
     slide-number: true
     show-slide-number: all
     preview-links: auto
     width: 1280
     height: 720
     theme: default
  pdf: default
editor: visual
execute:
  echo: true
---

## What is R?

-   R is.....

Render

Pulvinus answered 23/8, 2022 at 18:29 Comment(3)
Almost there! In this way I lost the presentation format.. I mean, the "slides".Chirm
are you referring to the slide number 1/2 on the top right corner of the html? I do have them...Pulvinus
When I do it, I have just the texts in pages. Like a word document. Not in the presentation format.Chirm
P
0

I got this to work in line with previous answer from shafee, but had to add an empty styles.css file to the working directory for pagedown::chrome_print() to not error on not finding the css file.

Phipps answered 9/9, 2022 at 12:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.