use highlight.js theme in rmarkdown::html_document() .Rmd - r

Can I specify a highlight.js style in RMarkdown front matter when using html_document?
example:
Instead of using pandoc's espresso highlighting say I want highlight.js's tommorrow highlithing which lives here
---
title: "Untitled"
output:
html_document:
highlight: espresso
---
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>.
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:
```{r}
summary(cars)
```
etc...
How might I do this?

As far as I know, there is not built-in way to do this but you can add the following lines at the beginning of your Rmd document to get what you want:
<style type="text/css">
#import "https://highlightjs.org/static/demo/styles/tomorrow.css";
</style>

Related

How I can freeze tabs using {.tabset} and a CSS in Rmarkdown?

I want to freeze the tabs bar at the top of the HTML page while scrolling down so that it always appears at the top..
This is an example for the code that I am using but without freezing the tabs.
---
title:
output:
html_document:
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# {.tabset .tabset-fade .tabset-pills}
## R Markdown {.tabset}
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>.
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:
```{r cars}
summary(cars)
```
<br><br><br>
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:
<br><br><br>
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>.
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:
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>.
<br><br><br><br>
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:
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>.
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:
<br><br><br><br> <br><br>
## Including Plots {.tabset}
## Dropdown Menu {.tabset}

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
---

When knitting an Rmd file to pdf, hashtags in links to bookdown books are converted to %23 and don't work

When I knit the following Rmd file to pdf, the # in the link to the bookdown book is converted to %23 and doesn't work. The link works fine if the Rmd is knitted to html instead of pdf.
I tried escaping the # with \ and \\; neither worked.
---
output: pdf_document
urlcolor: blue
---
This link does not work in the rendered pdf:
https://bookdown.org/yihui/bookdown/markdown-syntax.html#inline-formatting
Is there any way to get such a link to work in a rendered pdf document?
As per the comments, it's an issue with the PDF Viewer.
Reference: https://tex.stackexchange.com/questions/555559/href-broken-links-due-to-url-encoding-hash-sign-23

How to convert R reveal.js presentation to pdf?

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?

Export to PDF using rmarkdown render without PDF navigation buttons

I am using the render function from rmarkdown to export a .Rmd file to PDF.
The .Rmd file is the template generated within RStudio using
New File > R Markdown > Presentation > PDF (Beamer)
When export to PDF, each PDF page has navigation buttons at the bottom of the page which I would like to exclude during the export process. Below are the buttons.
Does anyone know how to exclude these navigation buttons?
You can add a command to turn them off in your header:
---
title: "Untitled"
output: beamer_presentation
header-includes:
- \beamertemplatenavigationsymbolsempty
---

Resources