-
Notifications
You must be signed in to change notification settings - Fork 0
/
VT-Beamer.Rmd
153 lines (93 loc) · 4.5 KB
/
VT-Beamer.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
---
title: "Virginia Tech Beamer Presentation"
author: Preston Childress
subtitle: "Some other text"
date: "`r format(Sys.time(), '%B %d, %Y')`" # This automatically sets date to today
institution: "Virginia Tech"
output:
beamer_presentation:
incremental: no #Don't make new slides for each bullet point
toc: no #No table of contents slide
theme: Hokie
latex_engine: pdflatex
slide_level: 2 # This makes double hashes slides, single hashes section titles
classoption: aspectratio=169 #Force widescreen
urlcolor: blue # urlcolor makes external hyperlinks blue as people expect
linkcolor: white # Ensure that the navigation dots are white for contrast
header-includes: \AtBeginSection{} # Turn off section header slides.
bibliography: "citations.bib" # This is the name of your citations file. An easy way to
# build a citations file is Zotero: https://zbib.org/
biblio-style: "apa.csl" # This is the APA citation style file, there are a LOT available:
# https://github.com/citation-style-language/styles
# nocite lets you include references from the .bib file without explicitly referring
# to them in the presentation body. References here MUST match whats in the .bib file.
nocite: "@rmdGuide, @ggplotBg, @rTheme, @rCodeFont, @rCrime"
---
```{r setup, include=FALSE}
# comment = NA turns off double hash marks on code outputs
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE, comment = NA, dev = 'pdf')
options(width = 120) # Make output wider so more code fits on a widescreen slide.
# This uses a 'size' option in knitr chunks and will change output size. eg {r size="tiny"}
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)
})
library(ggplot2)
# Transparent background for ggplot helps avoid overlapping the VT logo
theme_update(plot.background = element_rect(fill = "transparent",colour = NA))
# Other libraries can be imported here.
```
# Intro
## General Stuff
- You can make lists
- Sub-items are indented
- So are sub-sub-items
- And you can do in-line LaTeX: $e^{i\pi} + 1 = 0$
- Or in-line R syntax: `mean(mtcars$mpg)`
- LaTeX blocks are also supported:
$$ \overset{n}{\underset{i=1}{\sum}} \phi_i \frac{\mathbf{u}_i^\intercal \mathbf{b}}{\sigma_i} \mathbf{v}_i $$
# Code Section
## Code Example
- Code outputs with normal font size can use up vertical space quickly
```{r}
# This output is normalsize and takes up space
head(mtcars)
```
## Smaller Code
- The `size` parameter can be used to change code and output size
- It accepts standard LaTeX sizes:
- Huge > huge > LARGE > Large > large > normalsize > small > footnotesize > scriptsize > tiny
\footnotesize
```{r, size="footnotesize"}
# This output is footnotesize and takes up less space
head(mtcars)
```
## Plot Example
- Use `fig.width / fig.height` to scale plots
```{r fig.width = 6, fig.height = 2.25, size="footnotesize"}
# Code with {r fig.width = 6, fig.height = 2.25}
qplot(x = mtcars$wt, y = mtcars$mpg)
```
## Handling Overflow {.allowframebreaks}
- Sometimes code output will be too long for a single slide
- Adding `{.allowframebreaks}` to the title of a slide lets it overflow onto a second slide
- For this slide the header is `## Handling Overflow {.allowframebreaks}`
```{r size="footnotesize"}
# Intentionally long output
head(mtcars, 18)
```
- Output is continued to the second slide automatically
- The slide title automatically incremented
- The navigation dot does not advance
# References
## About References
- The References slide is created from a BibTeX `(.bib)` file declared at the top of this file
- Citation style is defined from a `.csl` file also declared at the top of this file
- Use `nocite` to include a citation in the bibliography without referencing it directly
- References can be cited in the presentation with `@referenceName` eg `@ggplotBg`: @ggplotBg
- Zotero is a good tool for building citation files: https://zbib.org/
- There are 1400+ citation style files available: https://github.com/citation-style-language/styles
- `{.allowframebreaks}` can be useful if there are many citations
## References
\footnotesize