Rmarkdown beamer: How to left justify the title page - r

How is it possible to align the title page of my Rmarkdown beamer presentation to the LEFT instead of the default center?
Example , default is center:
---
title: "Untitled"
author: "S SS"
date: "2/4/2018"
output: beamer_presentation
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## 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.

You can switch to a left aligned title page by using
\setbeamertemplate{title page}[default][left]
To use this in rmarkdown, place this line in a file called preamble.tex and use
---
title: "Untitled"
author: "S SS"
date: "2/4/2018"
output:
beamer_presentation:
includes:
in_header: preamble.tex
---
test
Edit:
with an up-to-date version of markdown, you can also directly do
---
title: "Untitled"
author: "S SS"
date: "2/4/2018"
output:
beamer_presentation
header-includes:
- \setbeamertemplate{title page}[default][left]
---
test

Here's a hack until someone comes along with a better answer: We'll dispense with a standard beamer title slide and just format the first slide as if it were a title slide:
---
output: beamer_presentation
header-includes:
- \usepackage{color}
---
\color{blue}
\LARGE{\textbf{This is the title}}
\color{black}
\vspace{0.2cm}
\large{Author Name}
\large{February 4, 2018}
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## 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.

Related

R error message output goes off the slide in beamer presentation R markdown

I'm using R markdown to make a beamer presentation.
When I try to include an error message output from R on the slide it goes off the page.
Here is my code:
---
title: "Untitled"
author: "John Smith"
date: '2022-04-29'
output: beamer_presentation
---
This error message goes off the page
```{r cars, echo = TRUE, error=TRUE}
summary(carrrrrrrrrrrrrrrrs)
```
And, this is what the slides look like:
How do I keep the code on the page, either by putting it on multiple lines or reducing font size?
You can use the same technique as in Change representation (background-color & frame) of chunks in RMarkdown (with Beamer-Presentations) to redefine the verbatim environment in such a way that it uses the listings package. The listings package then allows you to both add line breaks and adjust the font size to your liking:
---
title: "Untitled"
author: "John Smith"
date: '2022-04-29'
output:
beamer_presentation:
keep_tex: true
header-includes:
- \let\verbatim\undefined
- \let\verbatimend\undefined
- \usepackage{listings}
- \lstnewenvironment{verbatim}{\lstset{breaklines=true,basicstyle=\ttfamily\footnotesize}}{}
---
This error message goes off the page
```{r cars, echo = TRUE, error=TRUE}
summary(carrrrrrrrrrrrrrrrs)
```

Wrap text around plots in Markdown for Word Document Export

There is currently a thread for how to Wrap text around plots in Markdown but this is only for knitting to HTML. I need to be able to place text next to a plot and output to a word document.
---
title: "Untitled"
author: "Your Name"
date: "May 27, 2020"
output: word_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
```{r pressure, echo=FALSE, out.width= "65%", out.extra='style="float:right; padding:10px"'}
plot(pressure)
```
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:
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing
of the R code that generated the plot.
Please advise.

header on first page and others

a header is created for pages 2+ with fancyhdr but how can you make the same header also appear on the first page?
here is the rmarkdown:
---
title: "Untitled"
classoption: landscape
output:
pdf_document:
number_sections: false
dev: pdf
keep_tex: false
toc: yes
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyhead[C]{center text}
- \fancyhead[R]{right text}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
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)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
Include \thispagestyle{fancy} in the beginning of your document (e.g. just after the yaml header) to make the first page fancy.
Edit to address your comment
If you want to have different center text in the first page you can have use if when you define \fancyhead
\fancyhead[C]{\ifnum\value{page}>1 center text \else \fi}

How do I use themes for R Markdown with github_document as output?

I was told to write a report in R Markdown with the following template:
---
title: "Data Dictionary"
output: github_document
date: "Last Updated: `r format(Sys.time(), '%d, %B, %Y at %H:%M')`"
---
I want to use readthedown theme from rmdformats package, however I could not find a tutorial on how to do so properly. My question is, is it possible to use a theme with this template? Any help would be appreciated!
Assuming you already have installed the package, remotes::install_github("juba/rmdformats"), just pass rmdformats::readthedown to the output YAML:
---
title: "Untitled"
date: "Last Updated: `r format(Sys.time(), '%d, %B, %Y at %H:%M')`"
output: rmdformats::readthedown
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
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)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

add image in title page of rmarkdown pdf

I am attempting to create an rmarkdown document. I have finally figured out a way to approach this, although it has taken quite some time. The last thing I would like to be able to do is to add an image to the title page of my pdf document.
The trouble I have is that my title page is defined by the top section of YAML. Below is the contents of my example.Rmd file. I use the Knit PDF button in RStudio to turn it into a PDF.
---
title: "This is a my document"
author: "Prepared by: Dan Wilson"
date: '`r paste("Date:",Sys.Date())`'
mainfont: Roboto Light
fontsize: 12pt
documentclass: report
output:
pdf_document:
latex_engine: xelatex
highlight: tango
---
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)
```
You can also embed plots, for example:
```{r, echo=FALSE}
plot(cars)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
If anyone has some tips that would allow me to put an image (logo.png) above my title that would be great.
Based on the previous solution, the following code does not require an auxiliary header.tex file. All contents are contained in the .Rmd file. The LaTeX commands are instead defined in a header-includes block in the YAML header. More info can be found here.
Replace my_graphic.png below with your local graphic file.
---
title: "A title page image should be above me"
header-includes:
- \usepackage{titling}
- \pretitle{\begin{center}\LARGE\includegraphics[width=12cm]{my_graphic.png}\\[\bigskipamount]}
- \posttitle{\end{center}}
output:
pdf_document:
toc: true
---
\newpage
# Section 1
Some text.
I was able to solve this using LaTeX package titling
---
title: "Untitled"
author: "Name"
date: "September 19, 2015"
output:
pdf_document:
includes:
in_header: header.tex
---
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)
```
You can also embed plots, for example:
```{r, echo=FALSE}
plot(cars)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
Where the header.tex should include the following code:
\usepackage{titling}
\pretitle{%
\begin{center}
\LARGE
\includegraphics[width=4cm,height=6cm]{logo.png}\\[\bigskipamount]
}
\posttitle{\end{center}}
and replace logo.png with the image you would like to use and make sure the file is in the root directory of your Rmd file. You can change image width and height to your needs. For more information on available options go to titling
For a beamer presentation you can do it like this:
title: "Title"
subtitle: "Subtitle"
author: "author"
date: "date"
header-includes:
- \titlegraphic{\centering \includegraphics[width=12cm]{titlepic.png}}
output:
beamer_presentation:
latex_engine: xelatex
theme: "metropolis"
highlight: "espresso"
classoption: "aspectratio=169"
The titlegraphic will be placed below your title text
For beamer presentation if you want an image at the bottom you can kind of cheat and add the image where the date line should be. Then if you want to insert date you can add institution (which is before date). the ![] should be tabbed (4 spaces from the far left of the page)
date: |
![](mypathtofile/myimage.png){width=3in}

Resources