How to convert R reveal.js presentation to pdf? - r

I made a presentation in R, using one of the reveal.js templates (using revealjs R package).
By default, its generating a html file and when opened for presentation it displays top part of the browser including bookmarks, filepath etc... I can turn off bookmarks bar but not the filepath part, I need to present this in a formal setting so exporting the presentation to pdf seems like a better option.
Does anyone know how to export it to pdf? Can I add anything in the YAML header so that the output will be pdf and not html?
Below is the sample code, it generates "test.html" file. I want to generate "test.pdf" while preserving all other properties of presentations e.g transitions, interactive plots etc...
---
title: "test"
output: revealjs::revealjs_presentation
---
## R Markdown
This is an R Markdown presentation. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.
## Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
## Slide with R Code and Output
```{r}
summary(cars)
```
## Slide with Plot
```{r, echo=FALSE}
plot(cars)
```

If a manual solution is OK for you (no automatic generation of PDFs when you knit):
Open your HTML file in the browser and add ?print-pdf to the URL, e. g.
http://index.html?print-pdf
You can then print the slides into PDF (e. g. with Ubuntu Linux + Firefox + "save to file" printing option).

you may use decktape to convert various HTML presentations to pdf
https://github.com/astefanutti/decktape
The links inside the presentation will be preserved, yet the presentation will not be interactive
If you just need to hide the browser interface while preserving interactivity, use fullscreen mode
e.g. in google chrome press F11

I know this is 3 years late, but why not just put Chrome in fullscreen view?

Related

With R Markdown or Quarto can I embed a comment in HTML output?

I would like to add "hidden" text (the GitHub repo and code file name) to a report that is rendered to HTML with R Markdown (or Quarto). Is there an easy way to save some text information so it will show up when I inspect a document in a browser but the text will not show for the casual consumer of the web page?
With Quarto (and similar for R Markdown):
---
format: html
---
This is some text.
<!-- This will be displayed in the page source code but not in the output. -->

Rmd: Make the figure larger when clicked on it

I have a Rmarkdown file where I include figures with
knitr::include_graphics
The figures show up in the knitted document nicely. However, when I'm reading the knitted document, if I want to focus on one figure, I use the zoom option of the browser, which is not ideal.
Is it possible to add open the figure in a larger window when clicked on it?
PS: I use gitbook and/or bookdown::html for the output format of my Rmd files.
You can try out the themes from rmdformats package which implement this feature. They call it lightbox. To enable,you just need to set lightbox to true in the RMD yaml.
Example:
---
title: "My document"
output:
rmdformats::downcute:
lightbox: true
---

IN R MARKDOWN, How Can I add a background image (HTML output)?

I'm trying to put an image as background for my R markdown document (HTML output) Instead of the black background. I Was searching everywhere in the documentation on how to do this but I can't seem to find any answer as it's my first time working with R Markdown.
I can't seem to know how to put the background image and how to divide it that way so I can have my content in the middle
I'm also trying to attach a Hyperlink to tablist option,in the Picture2 as you can see "Source" as for when I click on it, it directs me to an external page
but ## [Source] ("github.com/example") isn't working which was the syntax in the documentation.
this is my code till now ..
I hope you can help me with these two questions,
it's again : - How to set a background image to an HTML output on the whole page like the black background
and how can I make the click on " Source " or TabItem directs me to an external link?
Thank you
---
title: "Title"
author: "Nessy"
date: "2 3 2020"
output:
rmarkdown::html_document:
theme: lumen
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# {.tabset .tabset-fade}
## Analysis
## Source
Just posting the answers here so it can be marked as "answered." (Kindly mark this as answer when you're done and if this satisfies you).
1) Regarding background theme check this out: https://rpubs.com/thaufas/555157
2) Try [github](someurl) with no space in between. EDIT:
Regarding opening the link in markdown there try these links R Markdown - Hyperlink outside Rmd file or Linking to url with rmarkdown using Knit Word in Rstudio.

How do you prevent a tabset dropdown from pushing the content below it in RMarkdown

I am using RMarkdown to create a html document. I want to use a dropdown tabset, but I would like the dropdown menu to open up over the content of the tab, rather than pushing it down.
A minimal example is this:
---
title: "Untitled"
output: html_document
---
## R Markdown {.tabset .tabset-dropdown}
### Tab A
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
### Tab B
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
When I knit that I get a page that looks like this
Closed dropdown menu
Which looks as I'd expect. But when you click the dropdown menu it pushes the content down rather than opening over it.
Open dropdown menu
Is there a way to prevent the menu from pushing down the content?
I think it is a bug that has not been fixed yet.
Elaborating on my comment above: This was a proposed solution to your problem that does not seem to work anymore after an upgrade from Bootstrap 3 to 44.

how to remove the title slide from Rstudio ioslides presentation

I am using R Studio and R Markdown to create an ioslides presentation. I would like to eliminate the title slide, and begin the presentation with a normal slide. So far, I have tried removing the title from the YAML options, but this just results in a blank title page.
How can I remove the title page altogether?
my YAML options
---
output:
ioslides_presentation:
widescreen: true
---
You can try to customise the template file. You can find the path of the default one in your system by typing rmarkdown:::rmarkdown_system_file("rmd/ioslides/default.html") in the console.
The easiest way to play with it would be to copy it to the directory of your project, rename it and put additional YAML option like template: custom_template.html. Even though this might not be enough to remove the title slide completely, you can always customise it so it looks like the first slide of your presentation.

Resources