R Markdown: Creating Backgrounds for Powerpoints - r

I'm using R markdown to create a presentation, and I would really like to add a custom background on my opening slide and second slide. Currently, I have my potential themes on a separate PowerPoint document. Is there any way to add backgrounds like that?
Thanks!

To add a custom background, one can create a powerpoint template, e.g. my-styles.pptx where the background image is placed at the slide master.
Then create an Rmarkdown file like follows and place it in the same folder:
---
title: "Fancy Slides"
author: "Creative Author"
date: "2021-06-09"
output:
powerpoint_presentation:
reference_doc: my-styles.pptx
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
## Slide with R Output
```{r cars, echo = TRUE}
summary(cars)
```
More about this can be found in Yihui Xie et al. (2021) R Markdown: The Definitive Guide, Section 4.4.
Tested with RStudio Version 1.4.1714 and Powerpoint 2016.

Related

Include logo (image) on every page of R markdown pdf

I am trying to include my company logo in an R markdown report. The output has to be pdf. The logo has to be used as a template on every page of the report in the top left of the file. Just for example, you can use this google logo https://en.wikipedia.org/wiki/Google#/media/File:Google_2015_logo.svg
I want the report to look like this (sorry for the blurry image but I just wanted to give an example) -
The google logo on top left should be present on every page.
I have done searches but all the searches that I have done are showing how to do this using latex or HTML output.
https://bookdown.org/yihui/rmarkdown-cookbook/latex-logo.html
Insert a logo in upper right corner of R markdown pdf document
2 Logo in R Markdown on PDF
add image in title page of rmarkdown pdf
The closest I have came is with this markdown document that is called reports.Rmd which looks like -
---
title: "Report"
output: pdf_document
params:
study: NA
mid : NA
---
![Caption.](google.png)
```{r, echo=FALSE}
paste0("Study : ", params$study)
paste0("ID", params$mid)
```
and I run this from another R script as -
library(rmarkdown)
study <- 'ABC'
mid <- '73023'
rmarkdown::render('reports.Rmd', pdf_document(), params = list(
study = study, mid = mid
))
This runs and produce this output
I'll be able to resize the image with How to set size for local image using knitr for markdown? but I don't know how to place this on top left of the page. Thank you for reading.
This is a template for you:
---
title: 'You are really need to use LaTeX'
author: "You"
date: "`r Sys.Date()`"
output:
pdf_document
header-includes:
\usepackage{fancyhdr}
\usepackage{graphicx}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
\addtolength{\headheight}{3.0cm}
\fancypagestyle{plain}{}
\pagestyle{fancy}
\fancyhead[R]{\includegraphics[width = 100pt]{your_pic.png}}
\renewcommand{\headrulewidth}{0pt}
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>.
and blah-blah...
So, don't forget to install LaTeX and packages fancyhdr, graphics.
How to do it, you can see there.
Or you can install MikTeX etc. You can find a lot of info at the SO/in the web.
The knowledge of LaTeX will save you not once a time in the future life ;)

Modify position of fancyhdr footer in R markdown

I have been searching to solve this issue for quite some time, but I cannot get it right. I use R markdown for creating a beamer presentation and I would like to include a footer by using the fancyhdr LaTeX package. The problem that I encounter is that the footer is not completely on each slide. I assume that it has to do something with the margins used by beamer, but I do not know how to change this.
Here is a MWE. This is the .rmd file:
---
title: "Untitled"
author: ""
date: "10 januari 2019"
output:
beamer_presentation:
includes:
in_header: preamble.tex
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## R Markdown
SOME NICE TEXT
This is in the file "preamble.tex" that is specified in the YAML:
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{}
\lfoot{Text in footer}
\cfoot{}
\rfoot{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
This is how it looks. The footer is not entirely on the slide:
Thank you in advance for your help!
When using beamer, it's much more natural to set the footline template than try to use fancyhdr like you'd use with, for example, and article class document (or a pdf_document in R Markdown world). Changing your preamble.tex to the following:
\setbeamertemplate{footline}
{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd = .5\paperwidth, ht = 1ex, dp = 1ex, center]{author in head/foot}%
Text in footer
\end{beamercolorbox}%
\begin{beamercolorbox}[wd = .5\paperwidth, ht = 1ex, dp = 1ex, center]{date in head/foot}%
\insertframenumber{}
\end{beamercolorbox}
}%
\vskip3pt%
}
\addtobeamertemplate{footline}{\begin{center}\rule{0.6\paperwidth}{0.4pt}\end{center}\vspace*{-1ex}}{}
results in this output:
which I believe is pretty close to what you want (the black bar there in the middle is just space between the slides in the PDF viewer I was using); you can tweak the footline definition until you get it precisely there.

Add special beamer slide using RMarkdown

I want to produce a beamer presentation from a RMarkdown file.
I am in this case using this beautiful template: https://github.com/matze/mtheme
How in markdown can you specify that you want to insert, not a "normal" slide, by a special one, such as an appendix slide, or a standout slide?
This template contains a standout slide that I would like to use as final slide as they do in their demo slides (http://mirrors.standaloneinstaller.com/ctan/macros/latex/contrib/beamer-contrib/themes/metropolis/demo/demo.pdf)
In beamer, I would do:
\begin{frame}[standout]
Questions?
\end{frame}
What is the equivalent in Markdown?
Setting frame options is pretty straight forward:
---
title: "Untitled"
output: beamer_presentation
theme: "metropolis"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## {.standout}
Questions?

rmarkdown beamer presentation: how to not print section slides?

I am writing a beamer presentation in rmarkdown and converting it to pdf with knitr. I want to define sections at the header1 level, e.g. # Introduction, and then have a slide titled something else e.g. ## Introducing my brilliant research. Having the header1 level define sections is nice as the names of the sections can be displayed in the slide header in certain beamer themes, and this is why I include it.
But I do not want rmarkdown to insert a slide that simply says the name of the section between sections, which at the moment it is doing. Is there a way to not print a slide with the section name between sections? I thought slide_level would control this behavior but it does not seem to (or perhaps I am using it wrong).
A minimal reproducible example of my problem can be obtained with this code:
---
title: "Test Pres"
author: "Professor Genius Researcher"
date: "24 February 2017"
output:
beamer_presentation:
slide_level: 2
theme: "Singapore"
colortheme: "rose"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
# Markdown Intro
## 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.
# Using Bullets
## Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
# Including Chunks
## Slide with R Output
```{r cars, echo = TRUE}
summary(cars)
```
## Slide with Plot
```{r pressure}
plot(pressure)
```
At the moment, this code produces slides that say Markdown Intro, Using Bullets, and Including Chunks. I would like those slides labeling the sections omitted. Is this possible?
Create a new Latex template where you remove this part from the preamble:
\AtBeginSection[]
{
....
}
Place this latex template in the same folder as your .Rmd file and refer to it in the Rmd Yaml front matter using template: mytemplate.tex as explained here.

How to Make RStudio Presentation Self-contained?

I'm writing a presentation in R using RStudio. To create new presentation, I select "R Presentation" from the File => New File menu. RStudio creates new document. Here is the template:
New Presentation
========================================================
author:
date:
First Slide
========================================================
For more details on authoring R presentations click the
**Help** button on the toolbar.
- Bullet 1
- Bullet 2
- Bullet 3
Slide With Code
========================================================
```{r}
summary(cars)
```
Slide With Plot
========================================================
```{r, echo=FALSE}
plot(cars)
```
Once a presentation is created, it can be saved as an HTML. However, I cannot find an option to make it a self-contained HTML file.
As a counter-example, I can create a self-contained HTML file using Rmarkdown:
---
title: "Habits"
output:
ioslides_presentation:
mathjax: local
self_contained: false
---
Source: http://rmarkdown.rstudio.com/ioslides_presentation_format.html
What is the equivalent of this code in RStudio R Presentation?
Additionally, does anyone know why they did it both ways?
SOLVED (09/25/2017)! See Nova's answer below. Here is a screenshot to show how I did it:
I've been able to "export" the presentation to html by going to the "Presentation" tab in RStudio, clicking the gear shift icon where it says "More", and choosing "Save as Webpage". This saved a stand-alone .html file that works when I open it from a different folder location.

Resources