---
title: "Title of the Talk"
author: "Author's name"
date: "`r format(Sys.time(), '%d %B %Y')`"
url: https://GitHubID.github.io/Repository/
github-repo: GitHubID/Repository
bibliography: references.bib
biblio-style: chicago
urlcolor: blue
output:
  bookdown::beamer_presentation2:
    latex_engine: xelatex
    includes:
      in_header: latex/header.tex
    citation_package: natbib
    slide_level: 2
    df_print: kable
    number_sections: no
    toc: no
    fig_caption: no
    keep_tex: no
  bookdown::slidy_presentation2:
    slide_level: 2
  bookdown::ioslides_presentation2:
    logo: images/logo.png
    widescreen: true
  bookdown::powerpoint_presentation2:
    slide_level: 2
---

```{r}
#| label: DoNotModify
#| include: false
### Utilities. Do not modify.
# Installation of packages if necessary
install_packages <- function(packages) {
  install_package <- function(package) {
    if (!package %in% installed.packages()[, 1]) {
      install.packages(package, repos = "https://cran.rstudio.com/")
    }
  }
  invisible(sapply(packages, install_package))
}

# Basic packages
install_packages(c("bookdown", "formatR", "kableExtra", "ragg"))

# Chunk font size hook: allows size='small' or any valid Latex font size in chunk options
def.chunk.hook  <- knitr::knit_hooks$get("chunk")
knitr::knit_hooks$set(chunk = function(x, options) {
  x <- def.chunk.hook(x, options)
  ifelse(
    options$size != "normalsize", 
    paste0("\n \\", options$size,"\n\n", x, "\n\n \\normalsize"),
    x
  )
})
```

```{r}
#| label: Options
#| include: false
### Customized options for this document
# Add necessary packages here
packages <- c("tidyverse")
# Install them
install_packages(packages)

# knitr options
knitr::opts_chunk$set(
  cache =   FALSE,    # Cache chunk results
  include = TRUE,     # Show/Hide chunks
  echo =    FALSE,    # Show/Hide code
  warning = FALSE,    # Show/Hide warnings
  message = FALSE,    # Show/Hide messages
  # Figure alignment and size
  fig.align = 'center', out.width = '80%',
  # Graphic devices (ragg_png is better than standard png)
  dev = c("ragg_png", "pdf"),
  # Code chunk format
  tidy = TRUE, tidy.opts = list(blank = FALSE, width.cutoff = 50),
  size = "scriptsize", knitr.graphics.auto_pdf = TRUE
)
options(width = 50)

# ggplot style
library("tidyverse")
theme_set(theme_bw())
theme_update(
  panel.background = element_rect(fill = "transparent", colour = NA),
  plot.background = element_rect(fill = "transparent", colour = NA)
)
knitr::opts_chunk$set(dev.args = list(bg = "transparent"))

# Tibbles: 5 lines, fit to slide width
options(tibble.print_min = 5, tibble.width = 50)

# Random seed
set.seed(973)
```


# Introduction

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

## Beamer Presentation Template

This template has the same features as others in the **memoiR** package except for
multi-language support (no `lang` item in the header).

See the code of the following slides for some specific code of slides.


# Advanced code

## Slide with Incremental Bullets

Incremental bullets start with `> -` instead of `-`:

> - Bullet 1
> - A reference: @Xie2016.
> - Bullet 3

## Slide with R Output

R code chunks are displayed as follows:

```{r}
#| label: cars
#| echo: true
head(cars)
```

## Slide with a Centered Plot{.flexbox .vcenter}

```{r}
#| label: pressure
plot(pressure)
```

## Two Column Layout{.columns-2} 

\begincols
  \begincol{.48\textwidth}

This slide has two columns.

In Beamer, each column in between `\begincol` and `\endcol`.

In HTML, the `{.columns-2}` option is added to the slide title and `<p class="forceBreak"></p>` allows forcing column break.


  \endcol
  \begincol{.48\textwidth}
  <p class="forceBreak"></p>

```{r}
#| label: pressure2
#| out-width: 90%
plot(pressure)
```

  \endcol
\endcols

## Documentation

See [R Markdown: The Definitive Guide](https://bookdown.org/yihui/rmarkdown/ioslides-presentation.html) for full documentation about HTML slides.

Note:

- `{.flexbox .vcenter}` to center the HTML slide with plot.
- `out.width='90%'` to reduce the size of the plot in the Two Column Layout slide.

Keep the code below to have a slide for references, allow two-column slides in _ioslides_ (but not in _Slidy_) and allow scrolling oversized slides.

<!-- A slide for references --> 
`r if (!knitr:::is_latex_output()) '## References {.smaller}'`
<!-- Styles for HTML slides -->
<!-- https://stackoverflow.com/questions/38260799/references-page-truncated-in-rmarkdown-ioslides-presentation/38294541#38294541 -->
<style>
  .forceBreak { -webkit-column-break-after: always; break-after: column; }
  slides > slide { overflow: scroll; }
  slides > slide:not(.nobackground):after { content: ''; }
</style>
