├── .Rbuildignore ├── .gitignore ├── DESCRIPTION ├── LICENSE ├── LICENSE.md ├── NAMESPACE ├── NEWS.md ├── README.Rmd ├── README.md ├── _pkgdown.yml ├── docs ├── .gitignore ├── 404.html ├── LICENSE-text.html ├── LICENSE.html ├── articles │ ├── index.html │ └── lecturenotes │ │ ├── css │ │ └── preamble.css │ │ ├── lecturenotes.html │ │ └── lecturenotes_files │ │ ├── figure-html │ │ └── mpg-1.png │ │ ├── kePrint-0.0.1 │ │ └── kePrint.js │ │ └── lightable-0.0.1 │ │ └── lightable.css ├── authors.html ├── deps │ ├── bootstrap-5.1.0 │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ └── bootstrap.min.css │ ├── data-deps.txt │ └── jquery-3.6.0 │ │ ├── jquery-3.6.0.js │ │ ├── jquery-3.6.0.min.js │ │ └── jquery-3.6.0.min.map ├── extra.css ├── index.html ├── link.svg ├── news │ └── index.html ├── pkgdown.js ├── pkgdown.yml ├── reference │ ├── figures │ │ ├── knitted-html.png │ │ ├── knitted-pdf.png │ │ └── mind-blown.gif │ └── index.html ├── samples │ ├── css │ │ └── preamble.css │ ├── lecturenotes.Rmd │ ├── lecturenotes.html │ ├── lecturenotes.pdf │ ├── lecturenotes_files │ │ ├── figure-html │ │ │ └── mpg-1.png │ │ └── figure-latex │ │ │ └── mpg-1.pdf │ └── tex │ │ ├── mytemplate.tex │ │ └── preamble.tex ├── search.json └── sitemap.xml ├── inst └── rmarkdown │ └── templates │ ├── lecturenotes-lean │ ├── skeleton │ │ ├── css │ │ │ └── preamble.css │ │ ├── skeleton.Rmd │ │ └── tex │ │ │ ├── mytemplate.tex │ │ │ └── preamble.tex │ └── template.yaml │ └── lecturenotes │ ├── skeleton │ ├── css │ │ └── preamble.css │ ├── skeleton.Rmd │ └── tex │ │ ├── mytemplate.tex │ │ └── preamble.tex │ └── template.yaml ├── lecturenotes.Rproj ├── man └── figures │ └── mind-blown.gif └── pkgdown └── extra.css /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^renv$ 2 | ^renv\.lock$ 3 | ^.*\.Rproj$ 4 | ^\.Rproj\.user$ 5 | ^README\.Rmd$ 6 | ^_pkgdown\.yml$ 7 | ^docs$ 8 | ^pkgdown$ 9 | ^\.github$ 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | **/*_cache/ 6 | **/skeleton.html 7 | **/skeleton.pdf 8 | **/skeleton_files/ 9 | **/*.log 10 | #docs 11 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: lecturenotes 2 | Type: Package 3 | Title: My lecture notes Rmd template 4 | Version: 0.2.2 5 | Authors@R: 6 | person(given = "Grant", 7 | family = "McDermott", 8 | role = c("aut", "cre"), 9 | email = "grantmcd@uoregon.edu", 10 | comment = c(ORCID = "0000-0001-7883-8573")) 11 | Description: Template for exporting to both HTML and PDF formats. Takes care of 12 | various annoyances like missing affiliation headings for PDF, handling of 13 | non-standard fonts, correct parsing of interactive content depending on the 14 | output format, etc. 15 | License: MIT + file LICENSE 16 | Encoding: UTF-8 17 | LazyData: true 18 | URL: https://github.com/grantmcdermott/lecturenotes, 19 | http://grantmcdermott.com/lecturenotes 20 | BugReports: https://github.com/grantmcdermott/lecturenotes/issues 21 | Depends: 22 | R (>= 3.1.0) 23 | Imports: 24 | rmarkdown (>= 1.3) 25 | Suggests: 26 | dplyr, 27 | data.table, 28 | kableExtra, 29 | modelsummary(>= 0.9.5), 30 | ggplot2, 31 | hrbrthemes 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2020 2 | COPYRIGHT HOLDER: Grant McDermott 3 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2020 Grant McDermott 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | exportPattern("^[[:alpha:]]+") 2 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # lecturenotes 0.2.2 2 | 3 | * Add pkgdown site. 4 | 5 | # lecturenotes 0.2.1 6 | 7 | * Switch to Journal Bootswatch theme for html output. 8 | 9 | * Drop renv (overkill for a template) and move suggested packages to Description 10 | 11 | * Add a "lean" companion template, without any explanatory text or examples. 12 | 13 | # lecturenotes 0.2.0 14 | 15 | * Knit now automatically outputs to both html and pdf. 16 | 17 | * Support for threeparttables in LaTeX. 18 | 19 | # lecturenotes 0.1.0 20 | 21 | * Initial release 22 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | 6 | 7 | ```{r, include = FALSE} 8 | knitr::opts_chunk$set( 9 | collapse = TRUE, 10 | comment = "#>", 11 | fig.path = "man/figures/README-", 12 | out.width = "100%" 13 | ) 14 | ``` 15 | 16 | # An R Markdown template for writing lecture notes and academic papers 17 | 18 | ## Motivation 19 | 20 | **lecturenotes** is a personalised .Rmd template that I use 21 | for writing my lecture notes and academic papers. It is intended for documents 22 | that are going to be exported (i.e. "knitted") to both HTML and PDF formats. In 23 | so doing, it tries to take care of various annoyances and inconsistencies that 24 | arise between these two formats. For example: 25 | 26 | - Recognizing the author "affiliation" field in PDF documents. 27 | - Support for consistent multi-column environments in both HTML and PDF. 28 | - Consistent regression table output (e.g. threeparttables). 29 | - Support for non-standard fonts when knitting to PDF. 30 | - Sensible handling of interactive content depending on the output format. 31 | - Etc. 32 | 33 | You can view samples of the resulting output here: 34 | 35 | 1. [**HTML**](samples/lecturenotes.html) 36 | 37 | 2. [**PDF**](samples/lecturenotes.pdf) 38 | 39 | ## Installation and use 40 | 41 | I don't foresee submitting this bespoke package to CRAN. However, you can easily 42 | install it from GitHub: 43 | 44 | ``` r 45 | # install.packages("remotes") 46 | remotes::install_github("grantmcdermott/lecturenotes") 47 | ``` 48 | 49 | Note that I use several external packages in the template to demonstrate 50 | functionality. See the "Suggests" list at the bottom of the [DESCRIPTION](https://github.com/grantmcdermott/lecturenotes/blob/master/DESCRIPTION) 51 | file. If you want to have these installed automatically, then you can simply 52 | amend the above installation command to: 53 | 54 | ``` r 55 | # install.packages("remotes") 56 | remotes::install_github("grantmcdermott/lecturenotes", dependencies = TRUE) 57 | ``` 58 | 59 | Once the package is installed, open up the **lecturenotes** template in RStudio 60 | by navigating to: 61 | 62 | ``` 63 | File > New File > R Markdown > From Template > Lecture Notes (lecturenotes) 64 | ``` 65 | 66 | (You can also select a "lean" template version that just provides the scaffolding 67 | without any explanatory text or examples.) 68 | 69 | Clicking on the "Knit" button in RStudio will automatically output to both HTML 70 | and PDF. 71 | 72 | 73 | ## Limitations 74 | 75 | This R Markdown template was mostly designed for my own use. As such, it comes 76 | with no guarantees; although, please do let me know if you run into problems. 77 | Some potential limitations and requirements perhaps worth highlighting: 78 | 79 | - The PDF output has only been tested on a TexLive distribution using XeLaTeX. 80 | I cannot guarantee that other LaTeX distributions or engines will work without 81 | some tinkering. 82 | - Similarly, I have adopted some opinionated takes on optimal LaTeX fonts. I use 83 | [Cochineal](https://www.ctan.org/tex-archive/fonts/cochineal) as the main font 84 | and [Fira](https://www.ctan.org/tex-archive/fonts/fira) for the sans and mono 85 | fonts. You may need to change or comment out [these lines](https://github.com/grantmcdermott/lecturenotes/blob/master/inst/rmarkdown/templates/template-name/skeleton/skeleton.Rmd#L33-L35) 86 | of the template, depending on your own system and/or preferences. 87 | - The template generally does a good job of automatically handling interactive 88 | content depending on the output format. For example, it tries to ignore 89 | interactive content when exporting to PDF. One notable exception is rendering of 90 | GIFs. I provide an example of how to handle this manually in the template itself. 91 | 92 | ## Acknowledgements 93 | 94 | This template essentially pulls together a bunch of tips, tricks, and ideas that 95 | I've accumulated over time to fit my own idiosyncratic writing and formatting 96 | needs. Some of these I stumbled upon on myself, most of them I found the 97 | old-fashioned way (i.e. searching on the Internet). Here is a non-exhaustive 98 | list of helpful sources that I've drawn upon. 99 | 100 | - http://labrtorian.com/2019/08/26/rmarkdown-template-that-manages-academic-affiliations 101 | - https://bookdown.org/yihui/rmarkdown-cookbook/multi-column.html 102 | - https://pandoc.org/MANUAL.html#extension-fenced_divs 103 | - https://tex.stackexchange.com/q/135361 104 | - https://twitter.com/stevenvmiller/status/1351585981275758598 105 | 106 | ## License 107 | 108 | The material in this repository is made available under the 109 | [MIT license](http://opensource.org/licenses/mit-license.php). 110 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # An R Markdown template for writing lecture notes and academic papers 5 | 6 | ## Motivation 7 | 8 | **lecturenotes** is a personalised .Rmd template that I use for writing 9 | my lecture notes and academic papers. It is intended for documents that 10 | are going to be exported (i.e. “knitted”) to both HTML and PDF formats. 11 | In so doing, it tries to take care of various annoyances and 12 | inconsistencies that arise between these two formats. For example: 13 | 14 | - Recognizing the author “affiliation” field in PDF documents. 15 | - Support for consistent multi-column environments in both HTML and 16 | PDF. 17 | - Consistent regression table output (e.g. threeparttables). 18 | - Support for non-standard fonts when knitting to PDF. 19 | - Sensible handling of interactive content depending on the output 20 | format. 21 | - Etc. 22 | 23 | You can view samples of the resulting output here: 24 | 25 | 1. [**HTML**](samples/lecturenotes.html) 26 | 27 | 2. [**PDF**](samples/lecturenotes.pdf) 28 | 29 | ## Installation and use 30 | 31 | I don’t foresee submitting this bespoke package to CRAN. However, you 32 | can easily install it from GitHub: 33 | 34 | ``` r 35 | # install.packages("remotes") 36 | remotes::install_github("grantmcdermott/lecturenotes") 37 | ``` 38 | 39 | Note that I use several external packages in the template to demonstrate 40 | functionality. See the “Suggests” list at the bottom of the 41 | [DESCRIPTION](https://github.com/grantmcdermott/lecturenotes/blob/master/DESCRIPTION) 42 | file. If you want to have these installed automatically, then you can 43 | simply amend the above installation command to: 44 | 45 | ``` r 46 | # install.packages("remotes") 47 | remotes::install_github("grantmcdermott/lecturenotes", dependencies = TRUE) 48 | ``` 49 | 50 | Once the package is installed, open up the **lecturenotes** template in 51 | RStudio by navigating to: 52 | 53 | File > New File > R Markdown > From Template > Lecture Notes (lecturenotes) 54 | 55 | (You can also select a “lean” template version that just provides the 56 | scaffolding without any explanatory text or examples.) 57 | 58 | Clicking on the “Knit” button in RStudio will automatically output to 59 | both HTML and PDF. 60 | 61 | ## Limitations 62 | 63 | This R Markdown template was mostly designed for my own use. As such, it 64 | comes with no guarantees; although, please do let me know if you run 65 | into problems. Some potential limitations and requirements perhaps worth 66 | highlighting: 67 | 68 | - The PDF output has only been tested on a TexLive distribution using 69 | XeLaTeX. I cannot guarantee that other LaTeX distributions or 70 | engines will work without some tinkering. 71 | - Similarly, I have adopted some opinionated takes on optimal LaTeX 72 | fonts. I use 73 | [Cochineal](https://www.ctan.org/tex-archive/fonts/cochineal) as the 74 | main font and [Fira](https://www.ctan.org/tex-archive/fonts/fira) 75 | for the sans and mono fonts. You may need to change or comment out 76 | [these 77 | lines](https://github.com/grantmcdermott/lecturenotes/blob/master/inst/rmarkdown/templates/template-name/skeleton/skeleton.Rmd#L33-L35) 78 | of the template, depending on your own system and/or preferences. 79 | - The template generally does a good job of automatically handling 80 | interactive content depending on the output format. For example, it 81 | tries to ignore interactive content when exporting to PDF. One 82 | notable exception is rendering of GIFs. I provide an example of how 83 | to handle this manually in the template itself. 84 | 85 | ## Acknowledgements 86 | 87 | This template essentially pulls together a bunch of tips, tricks, and 88 | ideas that I’ve accumulated over time to fit my own idiosyncratic 89 | writing and formatting needs. Some of these I stumbled upon on myself, 90 | most of them I found the old-fashioned way (i.e. searching on the 91 | Internet). Here is a non-exhaustive list of helpful sources that I’ve 92 | drawn upon. 93 | 94 | - 95 | - 96 | - 97 | - 98 | - 99 | 100 | ## License 101 | 102 | The material in this repository is made available under the [MIT 103 | license](http://opensource.org/licenses/mit-license.php). 104 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: http://grantmcdermott.com/lecturenotes 2 | template: 3 | bootstrap: 5 4 | navbar: 5 | title: "lecturenotes" 6 | left: 7 | - text: "Home" 8 | href: index.html 9 | - text: "Samples" 10 | menu: 11 | - text: "HTML" 12 | href: "samples/lecturenotes.html" 13 | - text: "PDF" 14 | href: "samples/lecturenotes.pdf" 15 | right: 16 | - text: "News" 17 | href: "news/index.html" 18 | - icon: fa-github 19 | href: https://github.com/grantmcdermott/lecturenotes 20 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything... 2 | # /* 3 | # # Except the samples 4 | # !/.gitignore 5 | # !/lecturenotes* 6 | -------------------------------------------------------------------------------- /docs/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Page not found (404) • lecturenotes 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | Skip to contents 22 | 23 | 24 |
68 |
69 |
73 | 74 | Content not found. Please use links in the navbar. 75 | 76 |
77 |
78 | 79 | 80 |
84 | 85 | 89 | 90 |
91 |
92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /docs/LICENSE-text.html: -------------------------------------------------------------------------------- 1 | 2 | License • lecturenotes 6 | Skip to contents 7 | 8 | 9 |
48 |
49 |
53 | 54 |
YEAR: 2020
55 | COPYRIGHT HOLDER: Grant McDermott
56 | 
57 | 58 |
59 | 60 | 61 |
64 | 65 | 68 | 69 |
70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /docs/LICENSE.html: -------------------------------------------------------------------------------- 1 | 2 | MIT License • lecturenotes 6 | Skip to contents 7 | 8 | 9 |
48 |
49 |
53 | 54 |
55 | 56 |

Copyright (c) 2020 Grant McDermott

57 |

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

58 |

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

59 |

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

60 |
61 | 62 |
63 | 64 | 65 |
68 | 69 | 72 | 73 |
74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /docs/articles/index.html: -------------------------------------------------------------------------------- 1 | 2 | Articles • lecturenotes 6 | Skip to contents 7 | 8 | 9 |
48 |
49 |
52 | 53 |
54 |

All vignettes

55 |

56 | 57 |
Course title
58 |
59 |
60 |
61 | 62 | 63 |
66 | 67 | 70 | 71 |
72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /docs/articles/lecturenotes/css/preamble.css: -------------------------------------------------------------------------------- 1 | /* See: https://bookdown.org/yihui/rmarkdown-cookbook/multi-column.html */ 2 | .columns {display: flex; flex-basis: auto} 3 | -------------------------------------------------------------------------------- /docs/articles/lecturenotes/lecturenotes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Course title • lecturenotes 10 | 11 | 12 | 13 | 14 | 15 | 16 | 20 | 21 | 22 | Skip to contents 23 | 24 | 25 |
69 | 70 |
71 |
80 | 81 | 82 | 83 |
84 |

Before you begin 85 |

86 |

This template is for knitting R Markdown documents to both HTML and PDF format. It tries to take care of various inconsistencies between the two formats with minimum effort from the user. Just click “Knit” (in Rstudio) and it will automatically export to both formats. As the name suggests, I predominantly use it for my lecture notes. But I find that it works well for writing papers too.

87 |

See the package README for a longer description, as well as potential gotchas and limitations (e.g. font support for different LaTeX engines).

88 |
89 |
90 |

Template features 91 |

92 |

Here are some examples of features not available in vanilla R Markdown and how to use them.

93 |
94 |

Multi-column environments 95 |

96 |

Multi-column environments are supported via’s Pandoc’s fenced_divs syntax and some preamble sugar (bundled together with the template). For example, a two-column section would look like this.

97 |
98 |
99 |

Here is some example dplyr code.

100 |
101 | library(dplyr)
102 | 
103 | mtcars %>% 
104 |   group_by(am) %>% 
105 |   summarise(mean(mpg))    
106 |
## # A tibble: 2 × 2
107 | ##      am `mean(mpg)`
108 | ##   <dbl>       <dbl>
109 | ## 1     0        17.1
110 | ## 2     1        24.4
111 |
112 |
113 |

 

114 |
115 |
116 |

And the data.table equivalent.

117 |
118 | library(data.table)
119 | 
120 | mtcars_dt = as.data.table(mtcars)
121 | mtcars_dt[, mean(mpg), by = am]   
122 |
##       am       V1
123 | ##    <num>    <num>
124 | ## 1:     1 24.39231
125 | ## 2:     0 17.14737
126 |
127 |
128 |

 

129 |

The same idea can be extended to additional columns and the individual column widths are also adjustable.

130 |
131 |
132 |

Regression tables 133 |

134 |

I have fairly strong preferences about how regression tables should look (threeparttable FTW). Luckily, the fantastic modelsummary package has us covered for nice looking regression tables, particularly since it automatically supports different Rmd output formats and backends. (For example, via the equally excellent kableExtra package.) This makes it easy to produce regression tables that look good in both HTML and PDF… although the latter requires that the corresponding LaTeX packages be loaded first. This template loads those LaTeX packages automatically, so tables like the below Just WorkTM.

135 |
136 | library(fixest) ## For quick multi-model regression object
137 | 
138 | mods = feols(c(mpg, hp) ~ disp + csw(wt, drat) | cyl + vs, data = mtcars)
139 | 
140 | library(modelsummary)
141 | library(kableExtra)
142 | 
143 | msummary(
144 |   mods, 
145 |   title = "fixest: multi-model estimation", 
146 |   stars = TRUE,
147 |   gof_omit = "Adj|Pseudo|Log|AIC|BIC"
148 |   ) %>%
149 |   add_footnote(
150 |     c(paste("This footnote is pretty long. In fact, it runs over several lines",
151 |           "of standard PDF output. Luckily that's no problem thanks to",
152 |           "modelsummary, kableExtra, and threeparttable. As an aside, the",
153 |           "fixest package is also amazing and you should use it."),
154 |       "A shorter note."),
155 |     threeparttable = TRUE
156 |     ) %>%
157 |   kable_styling(latex_options = "hold_position") ## (Optional) Print table directly below code
158 | 159 | 162 | 163 | 165 | 168 | 171 | 174 | 177 | 178 | 179 | 180 | 183 | 186 | 189 | 192 | 195 | 196 | 197 | 199 | 202 | 205 | 208 | 211 | 212 | 213 | 216 | 219 | 222 | 225 | 228 | 229 | 230 | 232 | 235 | 238 | 241 | 244 | 245 | 246 | 249 | 251 | 254 | 256 | 259 | 260 | 261 | 263 | 265 | 268 | 270 | 273 | 274 | 275 | 278 | 281 | 284 | 287 | 290 | 291 | 292 | 295 | 298 | 301 | 304 | 307 | 308 | 309 | 312 | 315 | 318 | 321 | 324 | 325 | 326 | 329 | 332 | 335 | 338 | 341 | 342 | 343 | 346 | 349 | 352 | 355 | 358 | 359 | 360 | 363 | 366 | 369 | 372 | 375 | 376 | 377 | 378 | 379 | 382 | 383 | 384 | 387 | 388 | 389 | 390 | 393 | 394 |
160 | fixest: multi-model estimation 161 |
164 | 166 | mpg 167 | 169 | mpg 170 | 172 | hp 173 | 175 | hp 176 |
181 | disp 182 | 184 | 0.002 185 | 187 | 0.002 188 | 190 | 0.104 191 | 193 | 0.126+ 194 |
198 | 200 | (0.005) 201 | 203 | (0.005) 204 | 206 | (0.117) 207 | 209 | (0.031) 210 |
214 | wt 215 | 217 | −3.403 218 | 220 | −3.397 221 | 223 | −3.502 224 | 226 | 2.863 227 |
231 | 233 | (1.331) 234 | 236 | (1.168) 237 | 239 | (8.289) 240 | 242 | (6.026) 243 |
247 | drat 248 | 250 | 252 | 0.038 253 | 255 | 257 | 37.781 258 |
262 | 264 | 266 | (1.223) 267 | 269 | 271 | (44.566) 272 |
276 | Num.Obs. 277 | 279 | 32 280 | 282 | 32 283 | 285 | 32 286 | 288 | 32 289 |
293 | R2 294 | 296 | 0.839 297 | 299 | 0.839 300 | 302 | 0.721 303 | 305 | 0.756 306 |
310 | R2 Within 311 | 313 | 0.396 314 | 316 | 0.396 317 | 319 | 0.012 320 | 322 | 0.138 323 |
327 | Std.Errors 328 | 330 | by: cyl 331 | 333 | by: cyl 334 | 336 | by: cyl 337 | 339 | by: cyl 340 |
344 | FE: cyl 345 | 347 | X 348 | 350 | X 351 | 353 | X 354 | 356 | X 357 |
361 | FE: vs 362 | 364 | X 365 | 367 | X 368 | 370 | X 371 | 373 | X 374 |
380 | a This footnote is pretty long. In fact, it runs over several lines of standard PDF output. Luckily that’s no problem thanks to modelsummary, kableExtra, and threeparttable. As an aside, the fixest package is also amazing and you should use it. 381 |
385 | b A shorter note. 386 |
391 | + p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001 392 |
395 |
396 |
397 |

PDF support for non-standard fonts 398 |

399 |

This is an easy one; simply a matter of adding dev: cairo_pdf to the YAML. But it’s nice not having to remember that every time, no?

400 |

Note: As the figure caption suggests, to run this next chunk you’ll need to add Arial Narrow to your font book if it’s not installed on your system already.

401 |
402 | library(ggplot2)
403 | library(hrbrthemes)
404 | 
405 | ggplot(mtcars, aes(mpg, wt)) +
406 |   geom_point() +
407 |   labs(x = "Fuel efficiency (mpg)", y = "Weight (tons)",
408 |        title = "This plot uses Arial Narrow fonts",
409 |        caption = "Note: Fonts must be installed separately on your system.") + 
410 |   theme_ipsum()
411 |

412 |
413 |
414 |

Ignore interactive content when exporting to PDF 415 |

416 |

In general, this template tries to do a good job of automatically handling (i.e. ignoring) interactive content when exporting to PDF. A notable exception is with embedded interactive content like external GIFs. In this case, rather than typing the usual, say, ![](mind-blown.gif) directly in the Rmd file, you should include the figure with knitr::include_graphics in an R chunk. This will allow you to control whether it renders, conditional on output format. For example, the following chunk will render an actual GIF when the knit target is HTML format, versus a message when that target is PDF format.

417 |

418 |
419 |
420 |
422 |
423 | 424 | 425 | 426 |
430 | 431 | 435 | 436 |
437 |
438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | -------------------------------------------------------------------------------- /docs/articles/lecturenotes/lecturenotes_files/figure-html/mpg-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grantmcdermott/lecturenotes/fc36575acc56915c02b99d03aa268ea65d2cf49b/docs/articles/lecturenotes/lecturenotes_files/figure-html/mpg-1.png -------------------------------------------------------------------------------- /docs/articles/lecturenotes/lecturenotes_files/kePrint-0.0.1/kePrint.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function(){ 2 | if (typeof $('[data-toggle="tooltip"]').tooltip === 'function') { 3 | $('[data-toggle="tooltip"]').tooltip(); 4 | } 5 | if ($('[data-toggle="popover"]').popover === 'function') { 6 | $('[data-toggle="popover"]').popover(); 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /docs/articles/lecturenotes/lecturenotes_files/lightable-0.0.1/lightable.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * lightable v0.0.1 3 | * Copyright 2020 Hao Zhu 4 | * Licensed under MIT (https://github.com/haozhu233/kableExtra/blob/master/LICENSE) 5 | */ 6 | 7 | .lightable-minimal { 8 | border-collapse: separate; 9 | border-spacing: 16px 1px; 10 | width: 100%; 11 | margin-bottom: 10px; 12 | } 13 | 14 | .lightable-minimal td { 15 | margin-left: 5px; 16 | margin-right: 5px; 17 | } 18 | 19 | .lightable-minimal th { 20 | margin-left: 5px; 21 | margin-right: 5px; 22 | } 23 | 24 | .lightable-minimal thead tr:last-child th { 25 | border-bottom: 2px solid #00000050; 26 | empty-cells: hide; 27 | 28 | } 29 | 30 | .lightable-minimal tbody tr:first-child td { 31 | padding-top: 0.5em; 32 | } 33 | 34 | .lightable-minimal.lightable-hover tbody tr:hover { 35 | background-color: #f5f5f5; 36 | } 37 | 38 | .lightable-minimal.lightable-striped tbody tr:nth-child(even) { 39 | background-color: #f5f5f5; 40 | } 41 | 42 | .lightable-classic { 43 | border-top: 0.16em solid #111111; 44 | border-bottom: 0.16em solid #111111; 45 | width: 100%; 46 | margin-bottom: 10px; 47 | margin: 10px 5px; 48 | } 49 | 50 | .lightable-classic tfoot tr td { 51 | border: 0; 52 | } 53 | 54 | .lightable-classic tfoot tr:first-child td { 55 | border-top: 0.14em solid #111111; 56 | } 57 | 58 | .lightable-classic caption { 59 | color: #222222; 60 | } 61 | 62 | .lightable-classic td { 63 | padding-left: 5px; 64 | padding-right: 5px; 65 | color: #222222; 66 | } 67 | 68 | .lightable-classic th { 69 | padding-left: 5px; 70 | padding-right: 5px; 71 | font-weight: normal; 72 | color: #222222; 73 | } 74 | 75 | .lightable-classic thead tr:last-child th { 76 | border-bottom: 0.10em solid #111111; 77 | } 78 | 79 | .lightable-classic.lightable-hover tbody tr:hover { 80 | background-color: #F9EEC1; 81 | } 82 | 83 | .lightable-classic.lightable-striped tbody tr:nth-child(even) { 84 | background-color: #f5f5f5; 85 | } 86 | 87 | .lightable-classic-2 { 88 | border-top: 3px double #111111; 89 | border-bottom: 3px double #111111; 90 | width: 100%; 91 | margin-bottom: 10px; 92 | } 93 | 94 | .lightable-classic-2 tfoot tr td { 95 | border: 0; 96 | } 97 | 98 | .lightable-classic-2 tfoot tr:first-child td { 99 | border-top: 3px double #111111; 100 | } 101 | 102 | .lightable-classic-2 caption { 103 | color: #222222; 104 | } 105 | 106 | .lightable-classic-2 td { 107 | padding-left: 5px; 108 | padding-right: 5px; 109 | color: #222222; 110 | } 111 | 112 | .lightable-classic-2 th { 113 | padding-left: 5px; 114 | padding-right: 5px; 115 | font-weight: normal; 116 | color: #222222; 117 | } 118 | 119 | .lightable-classic-2 tbody tr:last-child td { 120 | border-bottom: 3px double #111111; 121 | } 122 | 123 | .lightable-classic-2 thead tr:last-child th { 124 | border-bottom: 1px solid #111111; 125 | } 126 | 127 | .lightable-classic-2.lightable-hover tbody tr:hover { 128 | background-color: #F9EEC1; 129 | } 130 | 131 | .lightable-classic-2.lightable-striped tbody tr:nth-child(even) { 132 | background-color: #f5f5f5; 133 | } 134 | 135 | .lightable-material { 136 | min-width: 100%; 137 | white-space: nowrap; 138 | table-layout: fixed; 139 | font-family: Roboto, sans-serif; 140 | border: 1px solid #EEE; 141 | border-collapse: collapse; 142 | margin-bottom: 10px; 143 | } 144 | 145 | .lightable-material tfoot tr td { 146 | border: 0; 147 | } 148 | 149 | .lightable-material tfoot tr:first-child td { 150 | border-top: 1px solid #EEE; 151 | } 152 | 153 | .lightable-material th { 154 | height: 56px; 155 | padding-left: 16px; 156 | padding-right: 16px; 157 | } 158 | 159 | .lightable-material td { 160 | height: 52px; 161 | padding-left: 16px; 162 | padding-right: 16px; 163 | border-top: 1px solid #eeeeee; 164 | } 165 | 166 | .lightable-material.lightable-hover tbody tr:hover { 167 | background-color: #f5f5f5; 168 | } 169 | 170 | .lightable-material.lightable-striped tbody tr:nth-child(even) { 171 | background-color: #f5f5f5; 172 | } 173 | 174 | .lightable-material.lightable-striped tbody td { 175 | border: 0; 176 | } 177 | 178 | .lightable-material.lightable-striped thead tr:last-child th { 179 | border-bottom: 1px solid #ddd; 180 | } 181 | 182 | .lightable-material-dark { 183 | min-width: 100%; 184 | white-space: nowrap; 185 | table-layout: fixed; 186 | font-family: Roboto, sans-serif; 187 | border: 1px solid #FFFFFF12; 188 | border-collapse: collapse; 189 | margin-bottom: 10px; 190 | background-color: #363640; 191 | } 192 | 193 | .lightable-material-dark tfoot tr td { 194 | border: 0; 195 | } 196 | 197 | .lightable-material-dark tfoot tr:first-child td { 198 | border-top: 1px solid #FFFFFF12; 199 | } 200 | 201 | .lightable-material-dark th { 202 | height: 56px; 203 | padding-left: 16px; 204 | padding-right: 16px; 205 | color: #FFFFFF60; 206 | } 207 | 208 | .lightable-material-dark td { 209 | height: 52px; 210 | padding-left: 16px; 211 | padding-right: 16px; 212 | color: #FFFFFF; 213 | border-top: 1px solid #FFFFFF12; 214 | } 215 | 216 | .lightable-material-dark.lightable-hover tbody tr:hover { 217 | background-color: #FFFFFF12; 218 | } 219 | 220 | .lightable-material-dark.lightable-striped tbody tr:nth-child(even) { 221 | background-color: #FFFFFF12; 222 | } 223 | 224 | .lightable-material-dark.lightable-striped tbody td { 225 | border: 0; 226 | } 227 | 228 | .lightable-material-dark.lightable-striped thead tr:last-child th { 229 | border-bottom: 1px solid #FFFFFF12; 230 | } 231 | 232 | .lightable-paper { 233 | width: 100%; 234 | margin-bottom: 10px; 235 | color: #444; 236 | } 237 | 238 | .lightable-paper tfoot tr td { 239 | border: 0; 240 | } 241 | 242 | .lightable-paper tfoot tr:first-child td { 243 | border-top: 1px solid #00000020; 244 | } 245 | 246 | .lightable-paper thead tr:last-child th { 247 | color: #666; 248 | vertical-align: bottom; 249 | border-bottom: 1px solid #00000020; 250 | line-height: 1.15em; 251 | padding: 10px 5px; 252 | } 253 | 254 | .lightable-paper td { 255 | vertical-align: middle; 256 | border-bottom: 1px solid #00000010; 257 | line-height: 1.15em; 258 | padding: 7px 5px; 259 | } 260 | 261 | .lightable-paper.lightable-hover tbody tr:hover { 262 | background-color: #F9EEC1; 263 | } 264 | 265 | .lightable-paper.lightable-striped tbody tr:nth-child(even) { 266 | background-color: #00000008; 267 | } 268 | 269 | .lightable-paper.lightable-striped tbody td { 270 | border: 0; 271 | } 272 | 273 | -------------------------------------------------------------------------------- /docs/authors.html: -------------------------------------------------------------------------------- 1 | 2 | Authors and Citation • lecturenotes 6 | Skip to contents 7 | 8 | 9 |
48 |
49 |
52 | 53 |
54 |

Authors

55 | 56 |
  • 57 |

    Grant McDermott. Author, maintainer. 58 |

    59 |
  • 60 |
61 | 62 |
63 |

Citation

64 |

Source: DESCRIPTION

65 | 66 |

McDermott G (2022). 67 | lecturenotes: My lecture notes Rmd template. 68 | https://github.com/grantmcdermott/lecturenotes, 69 | http://grantmcdermott.com/lecturenotes. 70 |

71 |
@Manual{,
72 |   title = {lecturenotes: My lecture notes Rmd template},
73 |   author = {Grant McDermott},
74 |   year = {2022},
75 |   note = {https://github.com/grantmcdermott/lecturenotes,
76 | http://grantmcdermott.com/lecturenotes},
77 | }
78 |
79 |
81 | 82 | 83 |
86 | 87 | 90 | 91 |
92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /docs/deps/data-deps.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /docs/extra.css: -------------------------------------------------------------------------------- 1 | /* pkgdown/extra.css */ 2 | .row > main { 3 | max-width: 75%; 4 | } 5 | 6 | @media 7 | (min-width: 1400px) { 8 | main + .col-md-3 { 9 | margin-left: unset; 10 | padding-left: 5rem; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | My lecture notes Rmd template • lecturenotes 13 | 14 | 15 | 16 | 17 | 18 | 19 | 23 | 27 | 28 | 29 | Skip to contents 30 | 31 | 32 |
76 |
77 |
78 | 80 | 81 | 82 |
83 |

Motivation 84 |

85 |

lecturenotes is a personalised .Rmd template that I use for writing my lecture notes and academic papers. It is intended for documents that are going to be exported (i.e. “knitted”) to both HTML and PDF formats. In so doing, it tries to take care of various annoyances and inconsistencies that arise between these two formats. For example:

86 |
    87 |
  • Recognizing the author “affiliation” field in PDF documents.
  • 88 |
  • Support for consistent multi-column environments in both HTML and PDF.
  • 89 |
  • Consistent regression table output (e.g. threeparttables).
  • 90 |
  • Support for non-standard fonts when knitting to PDF.
  • 91 |
  • Sensible handling of interactive content depending on the output format.
  • 92 |
  • Etc.
  • 93 |
94 |

You can view samples of the resulting output here:

95 |
    96 |
  1. HTML

  2. 97 |
  3. PDF

  4. 98 |
99 |
100 |
101 |

Installation and use 102 |

103 |

I don’t foresee submitting this bespoke package to CRAN. However, you can easily install it from GitHub:

104 |
105 | # install.packages("remotes")
106 | remotes::install_github("grantmcdermott/lecturenotes")
107 |

Note that I use several external packages in the template to demonstrate functionality. See the “Suggests” list at the bottom of the DESCRIPTION file. If you want to have these installed automatically, then you can simply amend the above installation command to:

108 |
109 | # install.packages("remotes")
110 | remotes::install_github("grantmcdermott/lecturenotes", dependencies = TRUE)
111 |

Once the package is installed, open up the lecturenotes template in RStudio by navigating to:

112 |
File > New File > R Markdown > From Template > Lecture Notes (lecturenotes)
113 |

(You can also select a “lean” template version that just provides the scaffolding without any explanatory text or examples.)

114 |

Clicking on the “Knit” button in RStudio will automatically output to both HTML and PDF.

115 |
116 |
117 |

Limitations 118 |

119 |

This R Markdown template was mostly designed for my own use. As such, it comes with no guarantees; although, please do let me know if you run into problems. Some potential limitations and requirements perhaps worth highlighting:

120 |
    121 |
  • The PDF output has only been tested on a TexLive distribution using XeLaTeX. I cannot guarantee that other LaTeX distributions or engines will work without some tinkering.
  • 122 |
  • Similarly, I have adopted some opinionated takes on optimal LaTeX fonts. I use Cochineal as the main font and Fira for the sans and mono fonts. You may need to change or comment out these lines of the template, depending on your own system and/or preferences.
  • 123 |
  • The template generally does a good job of automatically handling interactive content depending on the output format. For example, it tries to ignore interactive content when exporting to PDF. One notable exception is rendering of GIFs. I provide an example of how to handle this manually in the template itself.
  • 124 |
125 |
126 |
127 |

Acknowledgements 128 |

129 |

This template essentially pulls together a bunch of tips, tricks, and ideas that I’ve accumulated over time to fit my own idiosyncratic writing and formatting needs. Some of these I stumbled upon on myself, most of them I found the old-fashioned way (i.e. searching on the Internet). Here is a non-exhaustive list of helpful sources that I’ve drawn upon.

130 | 137 |
138 |
139 |

License 140 |

141 |

The material in this repository is made available under the MIT license.

142 |
143 |
144 |
183 |
184 | 185 | 186 |
190 | 191 | 195 | 196 |
197 |
198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /docs/news/index.html: -------------------------------------------------------------------------------- 1 | 2 | Changelog • lecturenotes 6 | Skip to contents 7 | 8 | 9 |
48 |
49 |
53 | 54 |
55 |

lecturenotes 0.2.2

56 |
  • Add pkgdown site.
  • 57 |
58 |
59 |

lecturenotes 0.2.1

60 |
  • Switch to Journal Bootswatch theme for html output.

  • 61 |
  • Drop renv (overkill for a template) and move suggested packages to Description

  • 62 |
  • Add a “lean” companion template, without any explanatory text or examples.

  • 63 |
64 |
65 |

lecturenotes 0.2.0

66 |
  • Knit now automatically outputs to both html and pdf.

  • 67 |
  • Support for threeparttables in LaTeX.

  • 68 |
69 |
70 |

lecturenotes 0.1.0

71 |
  • Initial release
  • 72 |
73 |
75 | 76 | 77 |
80 | 81 | 84 | 85 |
86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /docs/pkgdown.js: -------------------------------------------------------------------------------- 1 | /* http://gregfranko.com/blog/jquery-best-practices/ */ 2 | (function($) { 3 | $(function() { 4 | 5 | $('nav.navbar').headroom(); 6 | 7 | Toc.init({ 8 | $nav: $("#toc"), 9 | $scope: $("main h2, main h3, main h4, main h5, main h6") 10 | }); 11 | 12 | $('body').scrollspy({ 13 | target: '#toc', 14 | offset: 56 // headroom height 15 | }); 16 | 17 | // Activate popovers 18 | $('[data-bs-toggle="popover"]').popover({ 19 | container: 'body', 20 | html: true, 21 | trigger: 'focus', 22 | placement: "top", 23 | sanitize: false, 24 | }); 25 | 26 | $('[data-bs-toggle="tooltip"]').tooltip(); 27 | 28 | /* Clipboard --------------------------*/ 29 | 30 | function changeTooltipMessage(element, msg) { 31 | var tooltipOriginalTitle=element.getAttribute('data-original-title'); 32 | element.setAttribute('data-original-title', msg); 33 | $(element).tooltip('show'); 34 | element.setAttribute('data-original-title', tooltipOriginalTitle); 35 | } 36 | 37 | if(ClipboardJS.isSupported()) { 38 | $(document).ready(function() { 39 | var copyButton = ""; 40 | 41 | $("div.sourceCode").addClass("hasCopyButton"); 42 | 43 | // Insert copy buttons: 44 | $(copyButton).prependTo(".hasCopyButton"); 45 | 46 | // Initialize tooltips: 47 | $('.btn-copy-ex').tooltip({container: 'body'}); 48 | 49 | // Initialize clipboard: 50 | var clipboard = new ClipboardJS('[data-clipboard-copy]', { 51 | text: function(trigger) { 52 | return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, ""); 53 | } 54 | }); 55 | 56 | clipboard.on('success', function(e) { 57 | changeTooltipMessage(e.trigger, 'Copied!'); 58 | e.clearSelection(); 59 | }); 60 | 61 | clipboard.on('error', function() { 62 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); 63 | }); 64 | 65 | }); 66 | } 67 | 68 | /* Search marking --------------------------*/ 69 | var url = new URL(window.location.href); 70 | var toMark = url.searchParams.get("q"); 71 | var mark = new Mark("div.col-md-9"); 72 | if (toMark) { 73 | mark.mark(toMark, { 74 | accuracy: { 75 | value: "complementary", 76 | limiters: [",", ".", ":", "/"], 77 | } 78 | }); 79 | } 80 | 81 | /* Search --------------------------*/ 82 | /* Adapted from https://github.com/rstudio/bookdown/blob/2d692ba4b61f1e466c92e78fd712b0ab08c11d31/inst/resources/bs4_book/bs4_book.js#L25 */ 83 | // Initialise search index on focus 84 | var fuse; 85 | $("#search-input").focus(async function(e) { 86 | if (fuse) { 87 | return; 88 | } 89 | 90 | $(e.target).addClass("loading"); 91 | var response = await fetch($("#search-input").data("search-index")); 92 | var data = await response.json(); 93 | 94 | var options = { 95 | keys: ["what", "text", "code"], 96 | ignoreLocation: true, 97 | threshold: 0.1, 98 | includeMatches: true, 99 | includeScore: true, 100 | }; 101 | fuse = new Fuse(data, options); 102 | 103 | $(e.target).removeClass("loading"); 104 | }); 105 | 106 | // Use algolia autocomplete 107 | var options = { 108 | autoselect: true, 109 | debug: true, 110 | hint: false, 111 | minLength: 2, 112 | }; 113 | var q; 114 | async function searchFuse(query, callback) { 115 | await fuse; 116 | 117 | var items; 118 | if (!fuse) { 119 | items = []; 120 | } else { 121 | q = query; 122 | var results = fuse.search(query, { limit: 20 }); 123 | items = results 124 | .filter((x) => x.score <= 0.75) 125 | .map((x) => x.item); 126 | if (items.length === 0) { 127 | items = [{dir:"Sorry 😿",previous_headings:"",title:"No results found.",what:"No results found.",path:window.location.href}]; 128 | } 129 | } 130 | callback(items); 131 | } 132 | $("#search-input").autocomplete(options, [ 133 | { 134 | name: "content", 135 | source: searchFuse, 136 | templates: { 137 | suggestion: (s) => { 138 | if (s.title == s.what) { 139 | return `${s.dir} >
${s.title}
`; 140 | } else if (s.previous_headings == "") { 141 | return `${s.dir} >
${s.title}
> ${s.what}`; 142 | } else { 143 | return `${s.dir} >
${s.title}
> ${s.previous_headings} > ${s.what}`; 144 | } 145 | }, 146 | }, 147 | }, 148 | ]).on('autocomplete:selected', function(event, s) { 149 | window.location.href = s.path + "?q=" + q + "#" + s.id; 150 | }); 151 | }); 152 | })(window.jQuery || window.$) 153 | 154 | 155 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: 2.14.2 2 | pkgdown: 2.0.1 3 | pkgdown_sha: ~ 4 | articles: {} 5 | last_built: 2022-03-03T00:46Z 6 | urls: 7 | reference: http://grantmcdermott.com/lecturenotes/reference 8 | article: http://grantmcdermott.com/lecturenotes/articles 9 | 10 | -------------------------------------------------------------------------------- /docs/reference/figures/knitted-html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grantmcdermott/lecturenotes/fc36575acc56915c02b99d03aa268ea65d2cf49b/docs/reference/figures/knitted-html.png -------------------------------------------------------------------------------- /docs/reference/figures/knitted-pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grantmcdermott/lecturenotes/fc36575acc56915c02b99d03aa268ea65d2cf49b/docs/reference/figures/knitted-pdf.png -------------------------------------------------------------------------------- /docs/reference/figures/mind-blown.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grantmcdermott/lecturenotes/fc36575acc56915c02b99d03aa268ea65d2cf49b/docs/reference/figures/mind-blown.gif -------------------------------------------------------------------------------- /docs/reference/index.html: -------------------------------------------------------------------------------- 1 | 2 | • lecturenotes 6 | Skip to contents 7 | 8 | 9 |
48 |
49 |
52 | 53 | 54 |
55 | 56 | 57 |
60 | 61 | 64 | 65 |
66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /docs/samples/css/preamble.css: -------------------------------------------------------------------------------- 1 | /* See: https://bookdown.org/yihui/rmarkdown-cookbook/multi-column.html */ 2 | .columns {display: flex; flex-basis: auto} 3 | -------------------------------------------------------------------------------- /docs/samples/lecturenotes.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: Course title 3 | subtitle: Lecture title 4 | author: 5 | name: Your name 6 | affiliation: University | Course code 7 | # date: "`r format(Sys.time(), '%d %B %Y')`" ## Or "Lecture no." 8 | output: 9 | html_document: 10 | keep_md: false 11 | theme: journal 12 | highlight: haddock 13 | # code_folding: show 14 | toc: yes 15 | toc_depth: 4 16 | toc_float: yes 17 | css: css/preamble.css ## For multi-col environments 18 | pdf_document: 19 | latex_engine: xelatex 20 | keep_tex: false ## Change to true if want keep intermediate .tex file 21 | toc: true 22 | toc_depth: 3 23 | dev: cairo_pdf 24 | # fig_width: 7 ## Optional: Set default PDF figure width 25 | # fig_height: 6 ## Optional: Set default PDF figure height 26 | extra_dependencies: ['booktabs', 'threeparttable', 'float'] # "longtable" 27 | includes: 28 | in_header: tex/preamble.tex ## For multi-col environments 29 | pandoc_args: 30 | --template=tex/mytemplate.tex ## For affiliation field. See: https://bit.ly/2T191uZ 31 | always_allow_html: true 32 | urlcolor: blue 33 | mainfont: cochineal 34 | sansfont: Fira Sans 35 | monofont: Fira Code ## Although, see: https://tex.stackexchange.com/q/294362 36 | ## Automatically knit to both formats: 37 | knit: (function(inputFile, encoding) { 38 | rmarkdown::render(inputFile, encoding = encoding, 39 | output_format = 'all') 40 | }) 41 | --- 42 | 43 | ```{r setup, include=FALSE} 44 | knitr::opts_chunk$set(echo = TRUE, cache = TRUE, dpi=300, fig.align = "center") 45 | ``` 46 | 47 | ## Before you begin 48 | 49 | This template is for knitting R Markdown documents to *both* HTML and PDF format. It tries to take care of various inconsistencies between the two formats with minimum effort from the user. Just click "Knit" (in Rstudio) and it will automatically export to both formats. As the name suggests, I predominantly use it for my lecture notes. But I find that it works well for writing papers too. 50 | 51 | See the package [README](https://github.com/grantmcdermott/lecturenotes/blob/master/README.md) for a longer description, as well as potential gotchas and limitations (e.g. font support for different LaTeX engines). 52 | 53 | ## Template features 54 | 55 | Here are some examples of features not available in vanilla R Markdown and how to use them. 56 | 57 | ### Multi-column environments 58 | 59 | Multi-column environments are supported via's Pandoc's [fenced_divs](https://pandoc.org/MANUAL.html#extension-fenced_divs) syntax and some preamble sugar (bundled together with the template). For example, a two-column section would look like this. 60 | 61 | :::::: {.columns} 62 | ::: {.column width="48%" data-latex="{0.48\textwidth}"} 63 | Here is some example **dplyr** code. 64 | 65 | ```{r dplyr, message=FALSE} 66 | library(dplyr) 67 | 68 | mtcars %>% 69 | group_by(am) %>% 70 | summarise(mean(mpg)) 71 | ``` 72 | ::: 73 | 74 | ::: {.column width="4%" data-latex="{0.04\textwidth}"} 75 | \ 76 | ::: 77 | 78 | ::: {.column width="48%" data-latex="{0.48\textwidth}"} 79 | And the **data.table** equivalent. 80 | 81 | ```{r dt, message=FALSE} 82 | library(data.table) 83 | 84 | mtcars_dt = as.data.table(mtcars) 85 | mtcars_dt[, mean(mpg), by = am] 86 | ``` 87 | ::: 88 | :::::: 89 | \ 90 | 91 | The same idea can be extended to additional columns and the individual column widths are also adjustable. 92 | 93 | ### Regression tables 94 | 95 | I have fairly strong preferences about how regression tables should look (threeparttable FTW). Luckily, the fantastic **modelsummary** package has us covered for nice looking regression tables, particularly since it automatically supports different Rmd output formats and backends. (For example, via the equally excellent **kableExtra** package.) This makes it easy to produce regression tables that look good in both HTML and PDF... although the latter requires that the corresponding LaTeX packages be loaded first. This template loads those LaTeX packages automatically, so tables like the below Just Work^TM^. 96 | 97 | ```{r msummary, message=FALSE, warning=FALSE} 98 | library(modelsummary) 99 | library(kableExtra) 100 | 101 | mod = lm(mpg ~ vs * wt, mtcars) 102 | 103 | msummary( 104 | mod, 105 | vcov = list("iid", "hc1", "hc2", "hc3", ~cyl), ## Multiple SEs for our model 106 | stars = TRUE, 107 | gof_omit = "^(?!Std)" ## Optional 108 | ) %>% 109 | add_footnote( 110 | c("Wow, look at all those standard errors!", 111 | paste("This next footnote is pretty long. In fact, it runs over several", 112 | "lines of standard PDF output. Luckily that's no problem thanks to", 113 | "modelsummary, kableExtra, and threeparttable.") 114 | ), 115 | threeparttable = TRUE 116 | ) %>% 117 | kable_styling( 118 | latex_options = "hold_position", ## (Optional) Print table directly below code 119 | position = "center" ## (Optional) Center table 120 | ) 121 | ``` 122 | 123 | ### PDF support for non-standard fonts 124 | 125 | This is an easy one; simply a matter of adding `dev: cairo_pdf` to the YAML. But it's nice not having to remember that every time, no? 126 | 127 | *Note: As the figure caption suggests, to run this next chunk you'll need to add [Arial Narrow](https://docs.microsoft.com/en-us/typography/font-list/arial-narrow) to your font book if it's not installed on your system already.* 128 | 129 | ```{r mpg, message=FALSE} 130 | library(ggplot2) 131 | library(hrbrthemes) 132 | 133 | ggplot(mtcars, aes(mpg, wt)) + 134 | geom_point() + 135 | labs(x = "Fuel efficiency (mpg)", y = "Weight (tons)", 136 | title = "This plot uses Arial Narrow fonts", 137 | caption = "Note: Fonts must be installed separately on your system.") + 138 | theme_ipsum() 139 | ``` 140 | 141 | ### Ignore interactive content when exporting to PDF 142 | 143 | In general, this template tries to do a good job of automatically handling (i.e. ignoring) interactive content when exporting to PDF. A notable exception is with embedded interactive content like external GIFs. In this case, rather than typing the usual, say, `![](mind-blown.gif)` directly in the Rmd file, you should include the figure with `knitr::include_graphics` in an R chunk. This will allow you to control whether it renders, conditional on output format. For example, the following chunk will render an actual GIF when the knit target is HTML format, versus a message when that target is PDF format. 144 | 145 | ```{r gif_example, echo = FALSE, out.width='100%'} 146 | my_gif = 'https://github.com/grantmcdermott/lecturenotes/blob/master/man/figures/mind-blown.gif?raw=true' 147 | if (knitr::is_html_output()){ 148 | knitr::include_graphics(my_gif) 149 | } else { 150 | message("Sorry, this GIF is only available in the the HTML version of the notes.") 151 | } 152 | ``` 153 | -------------------------------------------------------------------------------- /docs/samples/lecturenotes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grantmcdermott/lecturenotes/fc36575acc56915c02b99d03aa268ea65d2cf49b/docs/samples/lecturenotes.pdf -------------------------------------------------------------------------------- /docs/samples/lecturenotes_files/figure-html/mpg-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grantmcdermott/lecturenotes/fc36575acc56915c02b99d03aa268ea65d2cf49b/docs/samples/lecturenotes_files/figure-html/mpg-1.png -------------------------------------------------------------------------------- /docs/samples/lecturenotes_files/figure-latex/mpg-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grantmcdermott/lecturenotes/fc36575acc56915c02b99d03aa268ea65d2cf49b/docs/samples/lecturenotes_files/figure-latex/mpg-1.pdf -------------------------------------------------------------------------------- /docs/samples/tex/mytemplate.tex: -------------------------------------------------------------------------------- 1 | % Options for packages loaded elsewhere 2 | \PassOptionsToPackage{unicode$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref} 3 | \PassOptionsToPackage{hyphens}{url} 4 | $if(colorlinks)$ 5 | \PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor} 6 | $endif$ 7 | $if(dir)$ 8 | $if(latex-dir-rtl)$ 9 | \PassOptionsToPackage{RTLdocument}{bidi} 10 | $endif$ 11 | $endif$ 12 | $if(CJKmainfont)$ 13 | \PassOptionsToPackage{space}{xeCJK} 14 | $endif$ 15 | % 16 | \documentclass[ 17 | $if(fontsize)$ 18 | $fontsize$, 19 | $endif$ 20 | $if(lang)$ 21 | $babel-lang$, 22 | $endif$ 23 | $if(papersize)$ 24 | $papersize$paper, 25 | $endif$ 26 | $if(beamer)$ 27 | ignorenonframetext, 28 | $if(handout)$ 29 | handout, 30 | $endif$ 31 | $if(aspectratio)$ 32 | aspectratio=$aspectratio$, 33 | $endif$ 34 | $endif$ 35 | $for(classoption)$ 36 | $classoption$$sep$, 37 | $endfor$ 38 | ]{$documentclass$} 39 | $if(beamer)$ 40 | $if(background-image)$ 41 | \usebackgroundtemplate{% 42 | \includegraphics[width=\paperwidth]{$background-image$}% 43 | } 44 | $endif$ 45 | \usepackage{pgfpages} 46 | \setbeamertemplate{caption}[numbered] 47 | \setbeamertemplate{caption label separator}{: } 48 | \setbeamercolor{caption name}{fg=normal text.fg} 49 | \beamertemplatenavigationsymbols$if(navigation)$$navigation$$else$empty$endif$ 50 | $for(beameroption)$ 51 | \setbeameroption{$beameroption$} 52 | $endfor$ 53 | % Prevent slide breaks in the middle of a paragraph 54 | \widowpenalties 1 10000 55 | \raggedbottom 56 | $if(section-titles)$ 57 | \setbeamertemplate{part page}{ 58 | \centering 59 | \begin{beamercolorbox}[sep=16pt,center]{part title} 60 | \usebeamerfont{part title}\insertpart\par 61 | \end{beamercolorbox} 62 | } 63 | \setbeamertemplate{section page}{ 64 | \centering 65 | \begin{beamercolorbox}[sep=12pt,center]{part title} 66 | \usebeamerfont{section title}\insertsection\par 67 | \end{beamercolorbox} 68 | } 69 | \setbeamertemplate{subsection page}{ 70 | \centering 71 | \begin{beamercolorbox}[sep=8pt,center]{part title} 72 | \usebeamerfont{subsection title}\insertsubsection\par 73 | \end{beamercolorbox} 74 | } 75 | \AtBeginPart{ 76 | \frame{\partpage} 77 | } 78 | \AtBeginSection{ 79 | \ifbibliography 80 | \else 81 | \frame{\sectionpage} 82 | \fi 83 | } 84 | \AtBeginSubsection{ 85 | \frame{\subsectionpage} 86 | } 87 | $endif$ 88 | $endif$ 89 | $if(beamerarticle)$ 90 | \usepackage{beamerarticle} % needs to be loaded first 91 | $endif$ 92 | $if(fontfamily)$ 93 | \usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$} 94 | $else$ 95 | \usepackage{lmodern} 96 | $endif$ 97 | $if(linestretch)$ 98 | \usepackage{setspace} 99 | $endif$ 100 | \usepackage{amssymb,amsmath} 101 | \usepackage{ifxetex,ifluatex} 102 | \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex 103 | \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc} 104 | \usepackage[utf8]{inputenc} 105 | \usepackage{textcomp} % provide euro and other symbols 106 | \else % if luatex or xetex 107 | $if(mathspec)$ 108 | \ifxetex 109 | \usepackage{mathspec} 110 | \else 111 | \usepackage{unicode-math} 112 | \fi 113 | $else$ 114 | \usepackage{unicode-math} 115 | $endif$ 116 | \defaultfontfeatures{Scale=MatchLowercase} 117 | \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} 118 | $if(mainfont)$ 119 | \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$} 120 | $endif$ 121 | $if(sansfont)$ 122 | \setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$} 123 | $endif$ 124 | $if(monofont)$ 125 | \setmonofont[$for(monofontoptions)$$monofontoptions$$sep$,$endfor$]{$monofont$} 126 | $endif$ 127 | $for(fontfamilies)$ 128 | \newfontfamily{$fontfamilies.name$}[$for(fontfamilies.options)$$fontfamilies.options$$sep$,$endfor$]{$fontfamilies.font$} 129 | $endfor$ 130 | $if(mathfont)$ 131 | $if(mathspec)$ 132 | \ifxetex 133 | \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} 134 | \else 135 | \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} 136 | \fi 137 | $else$ 138 | \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} 139 | $endif$ 140 | $endif$ 141 | $if(CJKmainfont)$ 142 | \ifxetex 143 | \usepackage{xeCJK} 144 | \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$} 145 | \fi 146 | $endif$ 147 | $if(luatexjapresetoptions)$ 148 | \ifluatex 149 | \usepackage[$for(luatexjapresetoptions)$$luatexjapresetoptions$$sep$,$endfor$]{luatexja-preset} 150 | \fi 151 | $endif$ 152 | $if(CJKmainfont)$ 153 | \ifluatex 154 | \usepackage[$for(luatexjafontspecoptions)$$luatexjafontspecoptions$$sep$,$endfor$]{luatexja-fontspec} 155 | \setmainjfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$} 156 | \fi 157 | $endif$ 158 | \fi 159 | $if(beamer)$ 160 | $if(theme)$ 161 | \usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$} 162 | $endif$ 163 | $if(colortheme)$ 164 | \usecolortheme{$colortheme$} 165 | $endif$ 166 | $if(fonttheme)$ 167 | \usefonttheme{$fonttheme$} 168 | $endif$ 169 | $if(mainfont)$ 170 | \usefonttheme{serif} % use mainfont rather than sansfont for slide text 171 | $endif$ 172 | $if(innertheme)$ 173 | \useinnertheme{$innertheme$} 174 | $endif$ 175 | $if(outertheme)$ 176 | \useoutertheme{$outertheme$} 177 | $endif$ 178 | $endif$ 179 | % Use upquote if available, for straight quotes in verbatim environments 180 | \IfFileExists{upquote.sty}{\usepackage{upquote}}{} 181 | \IfFileExists{microtype.sty}{% use microtype if available 182 | \usepackage[$for(microtypeoptions)$$microtypeoptions$$sep$,$endfor$]{microtype} 183 | \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts 184 | }{} 185 | $if(indent)$ 186 | $else$ 187 | \makeatletter 188 | \@ifundefined{KOMAClassName}{% if non-KOMA class 189 | \IfFileExists{parskip.sty}{% 190 | \usepackage{parskip} 191 | }{% else 192 | \setlength{\parindent}{0pt} 193 | \setlength{\parskip}{6pt plus 2pt minus 1pt}} 194 | }{% if KOMA class 195 | \KOMAoptions{parskip=half}} 196 | \makeatother 197 | $endif$ 198 | $if(verbatim-in-note)$ 199 | \usepackage{fancyvrb} 200 | $endif$ 201 | \usepackage{xcolor} 202 | \IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available 203 | \IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}} 204 | \hypersetup{ 205 | $if(title-meta)$ 206 | pdftitle={$title-meta$}, 207 | $endif$ 208 | $if(author-meta)$ 209 | pdfauthor={$author-meta$}, 210 | $endif$ 211 | $if(lang)$ 212 | pdflang={$lang$}, 213 | $endif$ 214 | $if(subject)$ 215 | pdfsubject={$subject$}, 216 | $endif$ 217 | $if(keywords)$ 218 | pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$}, 219 | $endif$ 220 | $if(colorlinks)$ 221 | colorlinks=true, 222 | linkcolor=$if(linkcolor)$$linkcolor$$else$Maroon$endif$, 223 | filecolor=$if(filecolor)$$filecolor$$else$Maroon$endif$, 224 | citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$, 225 | urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$, 226 | $else$ 227 | hidelinks, 228 | $endif$ 229 | pdfcreator={LaTeX via pandoc}} 230 | \urlstyle{same} % disable monospaced font for URLs 231 | $if(verbatim-in-note)$ 232 | \VerbatimFootnotes % allow verbatim text in footnotes 233 | $endif$ 234 | $if(geometry)$ 235 | $if(beamer)$ 236 | \geometry{$for(geometry)$$geometry$$sep$,$endfor$} 237 | $else$ 238 | \usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry} 239 | $endif$ 240 | $endif$ 241 | $if(beamer)$ 242 | \newif\ifbibliography 243 | $endif$ 244 | $if(listings)$ 245 | \usepackage{listings} 246 | \newcommand{\passthrough}[1]{#1} 247 | \lstset{defaultdialect=[5.3]Lua} 248 | \lstset{defaultdialect=[x86masm]Assembler} 249 | $endif$ 250 | $if(lhs)$ 251 | \lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{} 252 | $endif$ 253 | $if(highlighting-macros)$ 254 | $highlighting-macros$ 255 | $endif$ 256 | $if(tables)$ 257 | \usepackage{longtable,booktabs} 258 | $if(beamer)$ 259 | \usepackage{caption} 260 | % Make caption package work with longtable 261 | \makeatletter 262 | \def\fnum@table{\tablename~\thetable} 263 | \makeatother 264 | $else$ 265 | % Correct order of tables after \paragraph or \subparagraph 266 | \usepackage{etoolbox} 267 | \makeatletter 268 | \patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{} 269 | \makeatother 270 | % Allow footnotes in longtable head/foot 271 | \IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}} 272 | \makesavenoteenv{longtable} 273 | $endif$ 274 | $endif$ 275 | $if(graphics)$ 276 | \usepackage{graphicx} 277 | \makeatletter 278 | \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi} 279 | \def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi} 280 | \makeatother 281 | % Scale images if necessary, so that they will not overflow the page 282 | % margins by default, and it is still possible to overwrite the defaults 283 | % using explicit options in \includegraphics[width, height, ...]{} 284 | \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio} 285 | % Set default figure placement to htbp 286 | \makeatletter 287 | \def\fps@figure{htbp} 288 | \makeatother 289 | $endif$ 290 | $if(links-as-notes)$ 291 | % Make links footnotes instead of hotlinks: 292 | \DeclareRobustCommand{\href}[2]{#2\footnote{\url{#1}}} 293 | $endif$ 294 | $if(strikeout)$ 295 | \usepackage[normalem]{ulem} 296 | % Avoid problems with \sout in headers with hyperref 297 | \pdfstringdefDisableCommands{\renewcommand{\sout}{}} 298 | $endif$ 299 | \setlength{\emergencystretch}{3em} % prevent overfull lines 300 | \providecommand{\tightlist}{% 301 | \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} 302 | $if(numbersections)$ 303 | \setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$} 304 | $else$ 305 | \setcounter{secnumdepth}{-\maxdimen} % remove section numbering 306 | $endif$ 307 | $if(beamer)$ 308 | $else$ 309 | $if(block-headings)$ 310 | % Make \paragraph and \subparagraph free-standing 311 | \ifx\paragraph\undefined\else 312 | \let\oldparagraph\paragraph 313 | \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}} 314 | \fi 315 | \ifx\subparagraph\undefined\else 316 | \let\oldsubparagraph\subparagraph 317 | \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} 318 | \fi 319 | $endif$ 320 | $endif$ 321 | $if(pagestyle)$ 322 | \pagestyle{$pagestyle$} 323 | $endif$ 324 | $for(header-includes)$ 325 | $header-includes$ 326 | $endfor$ 327 | $if(lang)$ 328 | \ifxetex 329 | % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic) 330 | \usepackage{polyglossia} 331 | \setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$} 332 | $for(polyglossia-otherlangs)$ 333 | \setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$} 334 | $endfor$ 335 | \else 336 | \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel} 337 | $if(babel-newcommands)$ 338 | $babel-newcommands$ 339 | $endif$ 340 | \fi 341 | $endif$ 342 | $if(dir)$ 343 | \ifxetex 344 | % Load bidi as late as possible as it modifies e.g. graphicx 345 | \usepackage{bidi} 346 | \fi 347 | \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex 348 | \TeXXeTstate=1 349 | \newcommand{\RL}[1]{\beginR #1\endR} 350 | \newcommand{\LR}[1]{\beginL #1\endL} 351 | \newenvironment{RTL}{\beginR}{\endR} 352 | \newenvironment{LTR}{\beginL}{\endL} 353 | \fi 354 | $endif$ 355 | $if(natbib)$ 356 | \usepackage[$natbiboptions$]{natbib} 357 | \bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$} 358 | $endif$ 359 | $if(biblatex)$ 360 | \usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex} 361 | $for(bibliography)$ 362 | \addbibresource{$bibliography$} 363 | $endfor$ 364 | $endif$ 365 | $if(csl-refs)$ 366 | \newlength{\cslhangindent} 367 | \setlength{\cslhangindent}{1.5em} 368 | \newenvironment{cslreferences}% 369 | {$if(csl-hanging-indent)$\setlength{\parindent}{0pt}% 370 | \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces$endif$}% 371 | {\par} 372 | $endif$ 373 | 374 | $if(title)$ 375 | \title{$title$$if(thanks)$\thanks{$thanks$}$endif$} 376 | $endif$ 377 | $if(subtitle)$ 378 | $if(beamer)$ 379 | $else$ 380 | \usepackage{etoolbox} 381 | \makeatletter 382 | \providecommand{\subtitle}[1]{% add subtitle to \maketitle 383 | \apptocmd{\@title}{\par {\large #1 \par}}{}{} 384 | } 385 | \makeatother 386 | $endif$ 387 | \subtitle{$subtitle$} 388 | $endif$ 389 | \usepackage{authblk} 390 | $for(author)$ 391 | $if(author.name)$ 392 | $if(author.number)$ 393 | \author[$author.number$]{$author.name$} 394 | $else$ 395 | \author[]{$author.name$} 396 | $endif$ 397 | $if(author.affiliation)$ 398 | $if(author.email)$ 399 | \affil{$author.affiliation$ \thanks{$author.email$}} 400 | $else$ 401 | \affil{$author.affiliation$} 402 | $endif$ 403 | $endif$ 404 | $else$ 405 | \author{$author$} 406 | $endif$ 407 | $endfor$ 408 | \date{$date$} 409 | $if(beamer)$ 410 | $if(institute)$ 411 | \institute{$for(institute)$$institute$$sep$ \and $endfor$} 412 | $endif$ 413 | $if(titlegraphic)$ 414 | \titlegraphic{\includegraphics{$titlegraphic$}} 415 | $endif$ 416 | $if(logo)$ 417 | \logo{\includegraphics{$logo$}} 418 | $endif$ 419 | $endif$ 420 | 421 | \begin{document} 422 | $if(has-frontmatter)$ 423 | \frontmatter 424 | $endif$ 425 | $if(title)$ 426 | $if(beamer)$ 427 | \frame{\titlepage} 428 | $else$ 429 | \maketitle 430 | $endif$ 431 | $if(abstract)$ 432 | \begin{abstract} 433 | $abstract$ 434 | \end{abstract} 435 | $endif$ 436 | $endif$ 437 | 438 | $for(include-before)$ 439 | $include-before$ 440 | 441 | $endfor$ 442 | $if(toc)$ 443 | $if(toc-title)$ 444 | \renewcommand*\contentsname{$toc-title$} 445 | $endif$ 446 | $if(beamer)$ 447 | \begin{frame}[allowframebreaks] 448 | $if(toc-title)$ 449 | \frametitle{$toc-title$} 450 | $endif$ 451 | \tableofcontents[hideallsubsections] 452 | \end{frame} 453 | $else$ 454 | { 455 | $if(colorlinks)$ 456 | \hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$$endif$} 457 | $endif$ 458 | \setcounter{tocdepth}{$toc-depth$} 459 | \tableofcontents 460 | } 461 | $endif$ 462 | $endif$ 463 | $if(lot)$ 464 | \listoftables 465 | $endif$ 466 | $if(lof)$ 467 | \listoffigures 468 | $endif$ 469 | $if(linestretch)$ 470 | \setstretch{$linestretch$} 471 | $endif$ 472 | $if(has-frontmatter)$ 473 | \mainmatter 474 | $endif$ 475 | $body$ 476 | 477 | $if(has-frontmatter)$ 478 | \backmatter 479 | $endif$ 480 | $if(natbib)$ 481 | $if(bibliography)$ 482 | $if(biblio-title)$ 483 | $if(has-chapters)$ 484 | \renewcommand\bibname{$biblio-title$} 485 | $else$ 486 | \renewcommand\refname{$biblio-title$} 487 | $endif$ 488 | $endif$ 489 | $if(beamer)$ 490 | \begin{frame}[allowframebreaks]{$biblio-title$} 491 | \bibliographytrue 492 | $endif$ 493 | \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$} 494 | $if(beamer)$ 495 | \end{frame} 496 | $endif$ 497 | 498 | $endif$ 499 | $endif$ 500 | $if(biblatex)$ 501 | $if(beamer)$ 502 | \begin{frame}[allowframebreaks]{$biblio-title$} 503 | \bibliographytrue 504 | \printbibliography[heading=none] 505 | \end{frame} 506 | $else$ 507 | \printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$ 508 | $endif$ 509 | 510 | $endif$ 511 | $for(include-after)$ 512 | $include-after$ 513 | 514 | $endfor$ 515 | \end{document} 516 | -------------------------------------------------------------------------------- /docs/samples/tex/preamble.tex: -------------------------------------------------------------------------------- 1 | %% See: https://bookdown.org/yihui/rmarkdown-cookbook/multi-column.html 2 | %% I've made some additional adjustments based on my own preferences (e.g. cols 3 | %% should be top-aligned in case of uneven vertical length) 4 | \newenvironment{columns}[1][]{}{} 5 | 6 | \newenvironment{column}[1]{\begin{minipage}[t]{#1}\ignorespaces}{% 7 | \end{minipage} 8 | \ifhmode\unskip\fi 9 | \aftergroup\useignorespacesandallpars 10 | } 11 | 12 | \def\useignorespacesandallpars#1\ignorespaces\fi{% 13 | #1\fi\ignorespacesandallpars} 14 | 15 | \makeatletter 16 | \def\ignorespacesandallpars{% 17 | \@ifnextchar\par 18 | {\expandafter\ignorespacesandallpars\@gobble}% 19 | {}% 20 | } 21 | \makeatother 22 | -------------------------------------------------------------------------------- /docs/search.json: -------------------------------------------------------------------------------- 1 | [{"path":"http://grantmcdermott.com/lecturenotes/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2020 Grant McDermott Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"http://grantmcdermott.com/lecturenotes/articles/lecturenotes/lecturenotes.html","id":"before-you-begin","dir":"Articles > Lecturenotes","previous_headings":"","what":"Before you begin","title":"Course title","text":"template knitting R Markdown documents HTML PDF format. tries take care various inconsistencies two formats minimum effort user. Just click “Knit” (Rstudio) automatically export formats. name suggests, predominantly use lecture notes. find works well writing papers . See package README longer description, well potential gotchas limitations (e.g. font support different LaTeX engines).","code":""},{"path":"http://grantmcdermott.com/lecturenotes/articles/lecturenotes/lecturenotes.html","id":"template-features","dir":"Articles > Lecturenotes","previous_headings":"","what":"Template features","title":"Course title","text":"examples features available vanilla R Markdown use .","code":""},{"path":"http://grantmcdermott.com/lecturenotes/articles/lecturenotes/lecturenotes.html","id":"multi-column-environments","dir":"Articles > Lecturenotes","previous_headings":"Template features","what":"Multi-column environments","title":"Course title","text":"Multi-column environments supported via’s Pandoc’s fenced_divs syntax preamble sugar (bundled together template). example, two-column section look like . example dplyr code.   data.table equivalent.   idea can extended additional columns individual column widths also adjustable.","code":"library(dplyr) mtcars %>% group_by(am) %>% summarise(mean(mpg)) ## # A tibble: 2 × 2 ## am `mean(mpg)` ## ## 1 0 17.1 ## 2 1 24.4 library(data.table) mtcars_dt = as.data.table(mtcars) mtcars_dt[, mean(mpg), by = am] ## am V1 ## ## 1: 1 24.39231 ## 2: 0 17.14737"},{"path":"http://grantmcdermott.com/lecturenotes/articles/lecturenotes/lecturenotes.html","id":"regression-tables","dir":"Articles > Lecturenotes","previous_headings":"Template features","what":"Regression tables","title":"Course title","text":"fairly strong preferences regression tables look (threeparttable FTW). Luckily, fantastic modelsummary package us covered nice looking regression tables, particularly since automatically supports different Rmd output formats backends. (example, via equally excellent kableExtra package.) makes easy produce regression tables look good HTML PDF… although latter requires corresponding LaTeX packages loaded first. template loads LaTeX packages automatically, tables like Just WorkTM. fixest: multi-model estimation","code":"library(fixest) ## For quick multi-model regression object mods = feols(c(mpg, hp) ~ disp + csw(wt, drat) | cyl + vs, data = mtcars) library(modelsummary) library(kableExtra) msummary( mods, title = \"fixest: multi-model estimation\", stars = TRUE, gof_omit = \"Adj|Pseudo|Log|AIC|BIC\" ) %>% add_footnote( c(paste(\"This footnote is pretty long. In fact, it runs over several lines\", \"of standard PDF output. Luckily that's no problem thanks to\", \"modelsummary, kableExtra, and threeparttable. As an aside, the\", \"fixest package is also amazing and you should use it.\"), \"A shorter note.\"), threeparttable = TRUE ) %>% kable_styling(latex_options = \"hold_position\") ## (Optional) Print table directly below code"},{"path":"http://grantmcdermott.com/lecturenotes/articles/lecturenotes/lecturenotes.html","id":"pdf-support-for-non-standard-fonts","dir":"Articles > Lecturenotes","previous_headings":"Template features","what":"PDF support for non-standard fonts","title":"Course title","text":"easy one; simply matter adding dev: cairo_pdf YAML. ’s nice remember every time, ? Note: figure caption suggests, run next chunk ’ll need add Arial Narrow font book ’s installed system already.","code":"library(ggplot2) library(hrbrthemes) ggplot(mtcars, aes(mpg, wt)) + geom_point() + labs(x = \"Fuel efficiency (mpg)\", y = \"Weight (tons)\", title = \"This plot uses Arial Narrow fonts\", caption = \"Note: Fonts must be installed separately on your system.\") + theme_ipsum()"},{"path":"http://grantmcdermott.com/lecturenotes/articles/lecturenotes/lecturenotes.html","id":"ignore-interactive-content-when-exporting-to-pdf","dir":"Articles > Lecturenotes","previous_headings":"Template features","what":"Ignore interactive content when exporting to PDF","title":"Course title","text":"general, template tries good job automatically handling (.e. ignoring) interactive content exporting PDF. notable exception embedded interactive content like external GIFs. case, rather typing usual, say, ![](mind-blown.gif) directly Rmd file, include figure knitr::include_graphics R chunk. allow control whether renders, conditional output format. example, following chunk render actual GIF knit target HTML format, versus message target PDF format.","code":""},{"path":"http://grantmcdermott.com/lecturenotes/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Grant McDermott. Author, maintainer.","code":""},{"path":"http://grantmcdermott.com/lecturenotes/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"McDermott G (2022). lecturenotes: lecture notes Rmd template. https://github.com/grantmcdermott/lecturenotes, http://grantmcdermott.com/lecturenotes.","code":"@Manual{, title = {lecturenotes: My lecture notes Rmd template}, author = {Grant McDermott}, year = {2022}, note = {https://github.com/grantmcdermott/lecturenotes, http://grantmcdermott.com/lecturenotes}, }"},{"path":[]},{"path":"http://grantmcdermott.com/lecturenotes/index.html","id":"motivation","dir":"","previous_headings":"","what":"Motivation","title":"My lecture notes Rmd template","text":"lecturenotes personalised .Rmd template use writing lecture notes academic papers. intended documents going exported (.e. “knitted”) HTML PDF formats. , tries take care various annoyances inconsistencies arise two formats. example: Recognizing author “affiliation” field PDF documents. Support consistent multi-column environments HTML PDF. Consistent regression table output (e.g. threeparttables). Support non-standard fonts knitting PDF. Sensible handling interactive content depending output format. Etc. can view samples resulting output : HTML PDF","code":""},{"path":"http://grantmcdermott.com/lecturenotes/index.html","id":"installation-and-use","dir":"","previous_headings":"","what":"Installation and use","title":"My lecture notes Rmd template","text":"don’t foresee submitting bespoke package CRAN. However, can easily install GitHub: Note use several external packages template demonstrate functionality. See “Suggests” list bottom DESCRIPTION file. want installed automatically, can simply amend installation command : package installed, open lecturenotes template RStudio navigating : (can also select “lean” template version just provides scaffolding without explanatory text examples.) Clicking “Knit” button RStudio automatically output HTML PDF.","code":"# install.packages(\"remotes\") remotes::install_github(\"grantmcdermott/lecturenotes\") # install.packages(\"remotes\") remotes::install_github(\"grantmcdermott/lecturenotes\", dependencies = TRUE) File > New File > R Markdown > From Template > Lecture Notes (lecturenotes)"},{"path":"http://grantmcdermott.com/lecturenotes/index.html","id":"limitations","dir":"","previous_headings":"","what":"Limitations","title":"My lecture notes Rmd template","text":"R Markdown template mostly designed use. , comes guarantees; although, please let know run problems. potential limitations requirements perhaps worth highlighting: PDF output tested TexLive distribution using XeLaTeX. guarantee LaTeX distributions engines work without tinkering. Similarly, adopted opinionated takes optimal LaTeX fonts. use Cochineal main font Fira sans mono fonts. may need change comment lines template, depending system /preferences. template generally good job automatically handling interactive content depending output format. example, tries ignore interactive content exporting PDF. One notable exception rendering GIFs. provide example handle manually template .","code":""},{"path":"http://grantmcdermott.com/lecturenotes/index.html","id":"acknowledgements","dir":"","previous_headings":"","what":"Acknowledgements","title":"My lecture notes Rmd template","text":"template essentially pulls together bunch tips, tricks, ideas ’ve accumulated time fit idiosyncratic writing formatting needs. stumbled upon , found old-fashioned way (.e. searching Internet). non-exhaustive list helpful sources ’ve drawn upon. http://labrtorian.com/2019/08/26/rmarkdown-template--manages-academic-affiliations https://bookdown.org/yihui/rmarkdown-cookbook/multi-column.html https://pandoc.org/MANUAL.html#extension-fenced_divs https://tex.stackexchange.com/q/135361 https://twitter.com/stevenvmiller/status/1351585981275758598","code":""},{"path":"http://grantmcdermott.com/lecturenotes/index.html","id":"license","dir":"","previous_headings":"","what":"License","title":"My lecture notes Rmd template","text":"material repository made available MIT license.","code":""},{"path":"http://grantmcdermott.com/lecturenotes/news/index.html","id":"lecturenotes-022","dir":"Changelog","previous_headings":"","what":"lecturenotes 0.2.2","title":"lecturenotes 0.2.2","text":"Add pkgdown site.","code":""},{"path":"http://grantmcdermott.com/lecturenotes/news/index.html","id":"lecturenotes-021","dir":"Changelog","previous_headings":"","what":"lecturenotes 0.2.1","title":"lecturenotes 0.2.1","text":"Switch Journal Bootswatch theme html output. Drop renv (overkill template) move suggested packages Description Add “lean” companion template, without explanatory text examples.","code":""},{"path":"http://grantmcdermott.com/lecturenotes/news/index.html","id":"lecturenotes-020","dir":"Changelog","previous_headings":"","what":"lecturenotes 0.2.0","title":"lecturenotes 0.2.0","text":"Knit now automatically outputs html pdf. Support threeparttables LaTeX.","code":""},{"path":"http://grantmcdermott.com/lecturenotes/news/index.html","id":"lecturenotes-010","dir":"Changelog","previous_headings":"","what":"lecturenotes 0.1.0","title":"lecturenotes 0.1.0","text":"Initial release","code":""}] 2 | -------------------------------------------------------------------------------- /docs/sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | http://grantmcdermott.com/lecturenotes/404.html 5 | 6 | 7 | http://grantmcdermott.com/lecturenotes/LICENSE-text.html 8 | 9 | 10 | http://grantmcdermott.com/lecturenotes/LICENSE.html 11 | 12 | 13 | http://grantmcdermott.com/lecturenotes/articles/index.html 14 | 15 | 16 | http://grantmcdermott.com/lecturenotes/articles/lecturenotes/lecturenotes.html 17 | 18 | 19 | http://grantmcdermott.com/lecturenotes/authors.html 20 | 21 | 22 | http://grantmcdermott.com/lecturenotes/index.html 23 | 24 | 25 | http://grantmcdermott.com/lecturenotes/news/index.html 26 | 27 | 28 | http://grantmcdermott.com/lecturenotes/reference/index.html 29 | 30 | 31 | http://grantmcdermott.com/lecturenotes/samples/lecturenotes.html 32 | 33 | 34 | -------------------------------------------------------------------------------- /inst/rmarkdown/templates/lecturenotes-lean/skeleton/css/preamble.css: -------------------------------------------------------------------------------- 1 | /* See: https://bookdown.org/yihui/rmarkdown-cookbook/multi-column.html */ 2 | .columns {display: flex; flex-basis: auto} 3 | -------------------------------------------------------------------------------- /inst/rmarkdown/templates/lecturenotes-lean/skeleton/skeleton.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: Course title 3 | subtitle: Lecture title 4 | author: 5 | name: Your name 6 | affiliation: University | Course code 7 | # date: "`r format(Sys.time(), '%d %B %Y')`" ## Or "Lecture no." 8 | output: 9 | html_document: 10 | keep_md: false 11 | theme: journal 12 | highlight: haddock 13 | # code_folding: show 14 | toc: yes 15 | toc_depth: 4 16 | toc_float: yes 17 | css: css/preamble.css ## For multi-col environments 18 | pdf_document: 19 | latex_engine: xelatex 20 | keep_tex: false ## Change to true if want keep intermediate .tex file 21 | toc: true 22 | toc_depth: 3 23 | dev: cairo_pdf 24 | # fig_width: 7 ## Optional: Set default PDF figure width 25 | # fig_height: 6 ## Optional: Set default PDF figure height 26 | extra_dependencies: ['booktabs', 'threeparttable', 'float'] # "longtable" 27 | includes: 28 | in_header: tex/preamble.tex ## For multi-col environments 29 | pandoc_args: 30 | --template=tex/mytemplate.tex ## For affiliation field. See: https://bit.ly/2T191uZ 31 | always_allow_html: true 32 | urlcolor: blue 33 | mainfont: cochineal 34 | sansfont: Fira Sans 35 | monofont: Fira Code ## Although, see: https://tex.stackexchange.com/q/294362 36 | ## Automatically knit to both formats: 37 | knit: (function(inputFile, encoding) { 38 | rmarkdown::render(inputFile, encoding = encoding, 39 | output_format = 'all') 40 | }) 41 | --- 42 | 43 | ```{r setup, include=FALSE} 44 | knitr::opts_chunk$set(echo = TRUE, cache = TRUE, dpi=300) 45 | ``` 46 | 47 | -------------------------------------------------------------------------------- /inst/rmarkdown/templates/lecturenotes-lean/skeleton/tex/mytemplate.tex: -------------------------------------------------------------------------------- 1 | % Options for packages loaded elsewhere 2 | \PassOptionsToPackage{unicode$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref} 3 | \PassOptionsToPackage{hyphens}{url} 4 | $if(colorlinks)$ 5 | \PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor} 6 | $endif$ 7 | $if(dir)$ 8 | $if(latex-dir-rtl)$ 9 | \PassOptionsToPackage{RTLdocument}{bidi} 10 | $endif$ 11 | $endif$ 12 | $if(CJKmainfont)$ 13 | \PassOptionsToPackage{space}{xeCJK} 14 | $endif$ 15 | % 16 | \documentclass[ 17 | $if(fontsize)$ 18 | $fontsize$, 19 | $endif$ 20 | $if(lang)$ 21 | $babel-lang$, 22 | $endif$ 23 | $if(papersize)$ 24 | $papersize$paper, 25 | $endif$ 26 | $if(beamer)$ 27 | ignorenonframetext, 28 | $if(handout)$ 29 | handout, 30 | $endif$ 31 | $if(aspectratio)$ 32 | aspectratio=$aspectratio$, 33 | $endif$ 34 | $endif$ 35 | $for(classoption)$ 36 | $classoption$$sep$, 37 | $endfor$ 38 | ]{$documentclass$} 39 | $if(beamer)$ 40 | $if(background-image)$ 41 | \usebackgroundtemplate{% 42 | \includegraphics[width=\paperwidth]{$background-image$}% 43 | } 44 | $endif$ 45 | \usepackage{pgfpages} 46 | \setbeamertemplate{caption}[numbered] 47 | \setbeamertemplate{caption label separator}{: } 48 | \setbeamercolor{caption name}{fg=normal text.fg} 49 | \beamertemplatenavigationsymbols$if(navigation)$$navigation$$else$empty$endif$ 50 | $for(beameroption)$ 51 | \setbeameroption{$beameroption$} 52 | $endfor$ 53 | % Prevent slide breaks in the middle of a paragraph 54 | \widowpenalties 1 10000 55 | \raggedbottom 56 | $if(section-titles)$ 57 | \setbeamertemplate{part page}{ 58 | \centering 59 | \begin{beamercolorbox}[sep=16pt,center]{part title} 60 | \usebeamerfont{part title}\insertpart\par 61 | \end{beamercolorbox} 62 | } 63 | \setbeamertemplate{section page}{ 64 | \centering 65 | \begin{beamercolorbox}[sep=12pt,center]{part title} 66 | \usebeamerfont{section title}\insertsection\par 67 | \end{beamercolorbox} 68 | } 69 | \setbeamertemplate{subsection page}{ 70 | \centering 71 | \begin{beamercolorbox}[sep=8pt,center]{part title} 72 | \usebeamerfont{subsection title}\insertsubsection\par 73 | \end{beamercolorbox} 74 | } 75 | \AtBeginPart{ 76 | \frame{\partpage} 77 | } 78 | \AtBeginSection{ 79 | \ifbibliography 80 | \else 81 | \frame{\sectionpage} 82 | \fi 83 | } 84 | \AtBeginSubsection{ 85 | \frame{\subsectionpage} 86 | } 87 | $endif$ 88 | $endif$ 89 | $if(beamerarticle)$ 90 | \usepackage{beamerarticle} % needs to be loaded first 91 | $endif$ 92 | $if(fontfamily)$ 93 | \usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$} 94 | $else$ 95 | \usepackage{lmodern} 96 | $endif$ 97 | $if(linestretch)$ 98 | \usepackage{setspace} 99 | $endif$ 100 | \usepackage{amssymb,amsmath} 101 | \usepackage{ifxetex,ifluatex} 102 | \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex 103 | \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc} 104 | \usepackage[utf8]{inputenc} 105 | \usepackage{textcomp} % provide euro and other symbols 106 | \else % if luatex or xetex 107 | $if(mathspec)$ 108 | \ifxetex 109 | \usepackage{mathspec} 110 | \else 111 | \usepackage{unicode-math} 112 | \fi 113 | $else$ 114 | \usepackage{unicode-math} 115 | $endif$ 116 | \defaultfontfeatures{Scale=MatchLowercase} 117 | \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} 118 | $if(mainfont)$ 119 | \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$} 120 | $endif$ 121 | $if(sansfont)$ 122 | \setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$} 123 | $endif$ 124 | $if(monofont)$ 125 | \setmonofont[$for(monofontoptions)$$monofontoptions$$sep$,$endfor$]{$monofont$} 126 | $endif$ 127 | $for(fontfamilies)$ 128 | \newfontfamily{$fontfamilies.name$}[$for(fontfamilies.options)$$fontfamilies.options$$sep$,$endfor$]{$fontfamilies.font$} 129 | $endfor$ 130 | $if(mathfont)$ 131 | $if(mathspec)$ 132 | \ifxetex 133 | \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} 134 | \else 135 | \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} 136 | \fi 137 | $else$ 138 | \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} 139 | $endif$ 140 | $endif$ 141 | $if(CJKmainfont)$ 142 | \ifxetex 143 | \usepackage{xeCJK} 144 | \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$} 145 | \fi 146 | $endif$ 147 | $if(luatexjapresetoptions)$ 148 | \ifluatex 149 | \usepackage[$for(luatexjapresetoptions)$$luatexjapresetoptions$$sep$,$endfor$]{luatexja-preset} 150 | \fi 151 | $endif$ 152 | $if(CJKmainfont)$ 153 | \ifluatex 154 | \usepackage[$for(luatexjafontspecoptions)$$luatexjafontspecoptions$$sep$,$endfor$]{luatexja-fontspec} 155 | \setmainjfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$} 156 | \fi 157 | $endif$ 158 | \fi 159 | $if(beamer)$ 160 | $if(theme)$ 161 | \usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$} 162 | $endif$ 163 | $if(colortheme)$ 164 | \usecolortheme{$colortheme$} 165 | $endif$ 166 | $if(fonttheme)$ 167 | \usefonttheme{$fonttheme$} 168 | $endif$ 169 | $if(mainfont)$ 170 | \usefonttheme{serif} % use mainfont rather than sansfont for slide text 171 | $endif$ 172 | $if(innertheme)$ 173 | \useinnertheme{$innertheme$} 174 | $endif$ 175 | $if(outertheme)$ 176 | \useoutertheme{$outertheme$} 177 | $endif$ 178 | $endif$ 179 | % Use upquote if available, for straight quotes in verbatim environments 180 | \IfFileExists{upquote.sty}{\usepackage{upquote}}{} 181 | \IfFileExists{microtype.sty}{% use microtype if available 182 | \usepackage[$for(microtypeoptions)$$microtypeoptions$$sep$,$endfor$]{microtype} 183 | \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts 184 | }{} 185 | $if(indent)$ 186 | $else$ 187 | \makeatletter 188 | \@ifundefined{KOMAClassName}{% if non-KOMA class 189 | \IfFileExists{parskip.sty}{% 190 | \usepackage{parskip} 191 | }{% else 192 | \setlength{\parindent}{0pt} 193 | \setlength{\parskip}{6pt plus 2pt minus 1pt}} 194 | }{% if KOMA class 195 | \KOMAoptions{parskip=half}} 196 | \makeatother 197 | $endif$ 198 | $if(verbatim-in-note)$ 199 | \usepackage{fancyvrb} 200 | $endif$ 201 | \usepackage{xcolor} 202 | \IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available 203 | \IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}} 204 | \hypersetup{ 205 | $if(title-meta)$ 206 | pdftitle={$title-meta$}, 207 | $endif$ 208 | $if(author-meta)$ 209 | pdfauthor={$author-meta$}, 210 | $endif$ 211 | $if(lang)$ 212 | pdflang={$lang$}, 213 | $endif$ 214 | $if(subject)$ 215 | pdfsubject={$subject$}, 216 | $endif$ 217 | $if(keywords)$ 218 | pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$}, 219 | $endif$ 220 | $if(colorlinks)$ 221 | colorlinks=true, 222 | linkcolor=$if(linkcolor)$$linkcolor$$else$Maroon$endif$, 223 | filecolor=$if(filecolor)$$filecolor$$else$Maroon$endif$, 224 | citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$, 225 | urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$, 226 | $else$ 227 | hidelinks, 228 | $endif$ 229 | pdfcreator={LaTeX via pandoc}} 230 | \urlstyle{same} % disable monospaced font for URLs 231 | $if(verbatim-in-note)$ 232 | \VerbatimFootnotes % allow verbatim text in footnotes 233 | $endif$ 234 | $if(geometry)$ 235 | $if(beamer)$ 236 | \geometry{$for(geometry)$$geometry$$sep$,$endfor$} 237 | $else$ 238 | \usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry} 239 | $endif$ 240 | $endif$ 241 | $if(beamer)$ 242 | \newif\ifbibliography 243 | $endif$ 244 | $if(listings)$ 245 | \usepackage{listings} 246 | \newcommand{\passthrough}[1]{#1} 247 | \lstset{defaultdialect=[5.3]Lua} 248 | \lstset{defaultdialect=[x86masm]Assembler} 249 | $endif$ 250 | $if(lhs)$ 251 | \lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{} 252 | $endif$ 253 | $if(highlighting-macros)$ 254 | $highlighting-macros$ 255 | $endif$ 256 | $if(tables)$ 257 | \usepackage{longtable,booktabs} 258 | $if(beamer)$ 259 | \usepackage{caption} 260 | % Make caption package work with longtable 261 | \makeatletter 262 | \def\fnum@table{\tablename~\thetable} 263 | \makeatother 264 | $else$ 265 | % Correct order of tables after \paragraph or \subparagraph 266 | \usepackage{etoolbox} 267 | \makeatletter 268 | \patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{} 269 | \makeatother 270 | % Allow footnotes in longtable head/foot 271 | \IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}} 272 | \makesavenoteenv{longtable} 273 | $endif$ 274 | $endif$ 275 | $if(graphics)$ 276 | \usepackage{graphicx} 277 | \makeatletter 278 | \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi} 279 | \def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi} 280 | \makeatother 281 | % Scale images if necessary, so that they will not overflow the page 282 | % margins by default, and it is still possible to overwrite the defaults 283 | % using explicit options in \includegraphics[width, height, ...]{} 284 | \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio} 285 | % Set default figure placement to htbp 286 | \makeatletter 287 | \def\fps@figure{htbp} 288 | \makeatother 289 | $endif$ 290 | $if(links-as-notes)$ 291 | % Make links footnotes instead of hotlinks: 292 | \DeclareRobustCommand{\href}[2]{#2\footnote{\url{#1}}} 293 | $endif$ 294 | $if(strikeout)$ 295 | \usepackage[normalem]{ulem} 296 | % Avoid problems with \sout in headers with hyperref 297 | \pdfstringdefDisableCommands{\renewcommand{\sout}{}} 298 | $endif$ 299 | \setlength{\emergencystretch}{3em} % prevent overfull lines 300 | \providecommand{\tightlist}{% 301 | \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} 302 | $if(numbersections)$ 303 | \setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$} 304 | $else$ 305 | \setcounter{secnumdepth}{-\maxdimen} % remove section numbering 306 | $endif$ 307 | $if(beamer)$ 308 | $else$ 309 | $if(block-headings)$ 310 | % Make \paragraph and \subparagraph free-standing 311 | \ifx\paragraph\undefined\else 312 | \let\oldparagraph\paragraph 313 | \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}} 314 | \fi 315 | \ifx\subparagraph\undefined\else 316 | \let\oldsubparagraph\subparagraph 317 | \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} 318 | \fi 319 | $endif$ 320 | $endif$ 321 | $if(pagestyle)$ 322 | \pagestyle{$pagestyle$} 323 | $endif$ 324 | $for(header-includes)$ 325 | $header-includes$ 326 | $endfor$ 327 | $if(lang)$ 328 | \ifxetex 329 | % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic) 330 | \usepackage{polyglossia} 331 | \setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$} 332 | $for(polyglossia-otherlangs)$ 333 | \setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$} 334 | $endfor$ 335 | \else 336 | \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel} 337 | $if(babel-newcommands)$ 338 | $babel-newcommands$ 339 | $endif$ 340 | \fi 341 | $endif$ 342 | $if(dir)$ 343 | \ifxetex 344 | % Load bidi as late as possible as it modifies e.g. graphicx 345 | \usepackage{bidi} 346 | \fi 347 | \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex 348 | \TeXXeTstate=1 349 | \newcommand{\RL}[1]{\beginR #1\endR} 350 | \newcommand{\LR}[1]{\beginL #1\endL} 351 | \newenvironment{RTL}{\beginR}{\endR} 352 | \newenvironment{LTR}{\beginL}{\endL} 353 | \fi 354 | $endif$ 355 | $if(natbib)$ 356 | \usepackage[$natbiboptions$]{natbib} 357 | \bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$} 358 | $endif$ 359 | $if(biblatex)$ 360 | \usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex} 361 | $for(bibliography)$ 362 | \addbibresource{$bibliography$} 363 | $endfor$ 364 | $endif$ 365 | $if(csl-refs)$ 366 | \newlength{\cslhangindent} 367 | \setlength{\cslhangindent}{1.5em} 368 | \newenvironment{cslreferences}% 369 | {$if(csl-hanging-indent)$\setlength{\parindent}{0pt}% 370 | \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces$endif$}% 371 | {\par} 372 | $endif$ 373 | 374 | $if(title)$ 375 | \title{$title$$if(thanks)$\thanks{$thanks$}$endif$} 376 | $endif$ 377 | $if(subtitle)$ 378 | $if(beamer)$ 379 | $else$ 380 | \usepackage{etoolbox} 381 | \makeatletter 382 | \providecommand{\subtitle}[1]{% add subtitle to \maketitle 383 | \apptocmd{\@title}{\par {\large #1 \par}}{}{} 384 | } 385 | \makeatother 386 | $endif$ 387 | \subtitle{$subtitle$} 388 | $endif$ 389 | \usepackage{authblk} 390 | $for(author)$ 391 | $if(author.name)$ 392 | $if(author.number)$ 393 | \author[$author.number$]{$author.name$} 394 | $else$ 395 | \author[]{$author.name$} 396 | $endif$ 397 | $if(author.affiliation)$ 398 | $if(author.email)$ 399 | \affil{$author.affiliation$ \thanks{$author.email$}} 400 | $else$ 401 | \affil{$author.affiliation$} 402 | $endif$ 403 | $endif$ 404 | $else$ 405 | \author{$author$} 406 | $endif$ 407 | $endfor$ 408 | \date{$date$} 409 | $if(beamer)$ 410 | $if(institute)$ 411 | \institute{$for(institute)$$institute$$sep$ \and $endfor$} 412 | $endif$ 413 | $if(titlegraphic)$ 414 | \titlegraphic{\includegraphics{$titlegraphic$}} 415 | $endif$ 416 | $if(logo)$ 417 | \logo{\includegraphics{$logo$}} 418 | $endif$ 419 | $endif$ 420 | 421 | \begin{document} 422 | $if(has-frontmatter)$ 423 | \frontmatter 424 | $endif$ 425 | $if(title)$ 426 | $if(beamer)$ 427 | \frame{\titlepage} 428 | $else$ 429 | \maketitle 430 | $endif$ 431 | $if(abstract)$ 432 | \begin{abstract} 433 | $abstract$ 434 | \end{abstract} 435 | $endif$ 436 | $endif$ 437 | 438 | $for(include-before)$ 439 | $include-before$ 440 | 441 | $endfor$ 442 | $if(toc)$ 443 | $if(toc-title)$ 444 | \renewcommand*\contentsname{$toc-title$} 445 | $endif$ 446 | $if(beamer)$ 447 | \begin{frame}[allowframebreaks] 448 | $if(toc-title)$ 449 | \frametitle{$toc-title$} 450 | $endif$ 451 | \tableofcontents[hideallsubsections] 452 | \end{frame} 453 | $else$ 454 | { 455 | $if(colorlinks)$ 456 | \hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$$endif$} 457 | $endif$ 458 | \setcounter{tocdepth}{$toc-depth$} 459 | \tableofcontents 460 | } 461 | $endif$ 462 | $endif$ 463 | $if(lot)$ 464 | \listoftables 465 | $endif$ 466 | $if(lof)$ 467 | \listoffigures 468 | $endif$ 469 | $if(linestretch)$ 470 | \setstretch{$linestretch$} 471 | $endif$ 472 | $if(has-frontmatter)$ 473 | \mainmatter 474 | $endif$ 475 | $body$ 476 | 477 | $if(has-frontmatter)$ 478 | \backmatter 479 | $endif$ 480 | $if(natbib)$ 481 | $if(bibliography)$ 482 | $if(biblio-title)$ 483 | $if(has-chapters)$ 484 | \renewcommand\bibname{$biblio-title$} 485 | $else$ 486 | \renewcommand\refname{$biblio-title$} 487 | $endif$ 488 | $endif$ 489 | $if(beamer)$ 490 | \begin{frame}[allowframebreaks]{$biblio-title$} 491 | \bibliographytrue 492 | $endif$ 493 | \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$} 494 | $if(beamer)$ 495 | \end{frame} 496 | $endif$ 497 | 498 | $endif$ 499 | $endif$ 500 | $if(biblatex)$ 501 | $if(beamer)$ 502 | \begin{frame}[allowframebreaks]{$biblio-title$} 503 | \bibliographytrue 504 | \printbibliography[heading=none] 505 | \end{frame} 506 | $else$ 507 | \printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$ 508 | $endif$ 509 | 510 | $endif$ 511 | $for(include-after)$ 512 | $include-after$ 513 | 514 | $endfor$ 515 | \end{document} 516 | -------------------------------------------------------------------------------- /inst/rmarkdown/templates/lecturenotes-lean/skeleton/tex/preamble.tex: -------------------------------------------------------------------------------- 1 | %% See: https://bookdown.org/yihui/rmarkdown-cookbook/multi-column.html 2 | %% I've made some additional adjustments based on my own preferences (e.g. cols 3 | %% should be top-aligned in case of uneven vertical length) 4 | \newenvironment{columns}[1][]{}{} 5 | 6 | \newenvironment{column}[1]{\begin{minipage}[t]{#1}\ignorespaces}{% 7 | \end{minipage} 8 | \ifhmode\unskip\fi 9 | \aftergroup\useignorespacesandallpars 10 | } 11 | 12 | \def\useignorespacesandallpars#1\ignorespaces\fi{% 13 | #1\fi\ignorespacesandallpars} 14 | 15 | \makeatletter 16 | \def\ignorespacesandallpars{% 17 | \@ifnextchar\par 18 | {\expandafter\ignorespacesandallpars\@gobble}% 19 | {}% 20 | } 21 | \makeatother 22 | -------------------------------------------------------------------------------- /inst/rmarkdown/templates/lecturenotes-lean/template.yaml: -------------------------------------------------------------------------------- 1 | name: Lecture Notes lean 2 | description: > 3 | My Rmd lecture notes setup, designed for exporting to both HTML and PDF 4 | formats. Takes care of things like consistent multi-column environments and 5 | regression table output, support for non-standard fonts in figures, nice 6 | affiliation typesetting for PDF format, etc. 7 | 8 | Note: This "lean" version just includes the scaffolding without any 9 | explanatory code. 10 | create_dir: FALSE 11 | -------------------------------------------------------------------------------- /inst/rmarkdown/templates/lecturenotes/skeleton/css/preamble.css: -------------------------------------------------------------------------------- 1 | /* See: https://bookdown.org/yihui/rmarkdown-cookbook/multi-column.html */ 2 | .columns {display: flex; flex-basis: auto} 3 | -------------------------------------------------------------------------------- /inst/rmarkdown/templates/lecturenotes/skeleton/skeleton.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: Course title 3 | subtitle: Lecture title 4 | author: 5 | name: Your name 6 | affiliation: University | Course code 7 | # date: "`r format(Sys.time(), '%d %B %Y')`" ## Or "Lecture no." 8 | output: 9 | html_document: 10 | keep_md: false 11 | theme: journal 12 | highlight: haddock 13 | # code_folding: show 14 | toc: yes 15 | toc_depth: 4 16 | toc_float: yes 17 | css: css/preamble.css ## For multi-col environments 18 | pdf_document: 19 | latex_engine: xelatex 20 | keep_tex: false ## Change to true if want keep intermediate .tex file 21 | toc: true 22 | toc_depth: 3 23 | dev: cairo_pdf 24 | # fig_width: 7 ## Optional: Set default PDF figure width 25 | # fig_height: 6 ## Optional: Set default PDF figure height 26 | extra_dependencies: ['booktabs', 'threeparttable', 'float'] # "longtable" 27 | includes: 28 | in_header: tex/preamble.tex ## For multi-col environments 29 | pandoc_args: 30 | --template=tex/mytemplate.tex ## For affiliation field. See: https://bit.ly/2T191uZ 31 | always_allow_html: true 32 | urlcolor: blue 33 | mainfont: cochineal 34 | sansfont: Fira Sans 35 | monofont: Fira Code ## Although, see: https://tex.stackexchange.com/q/294362 36 | ## Automatically knit to both formats: 37 | knit: (function(inputFile, encoding) { 38 | rmarkdown::render(inputFile, encoding = encoding, 39 | output_format = 'all') 40 | }) 41 | --- 42 | 43 | ```{r setup, include=FALSE} 44 | knitr::opts_chunk$set(echo = TRUE, cache = TRUE, dpi=300) 45 | ``` 46 | 47 | ## Before you begin 48 | 49 | This template is for knitting R Markdown documents to *both* HTML and PDF format. It tries to take care of various inconsistencies between the two formats with minimum effort from the user. Just click "Knit" (in Rstudio) and it will automatically export to both formats. As the name suggests, I predominantly use it for my lecture notes. But I find that it works well for writing papers too. 50 | 51 | See the package [README](https://github.com/grantmcdermott/lecturenotes/blob/master/README.md) for a longer description, as well as potential gotchas and limitations (e.g. font support for different LaTeX engines). 52 | 53 | ## Template features 54 | 55 | Here are some examples of features not available in vanilla R Markdown and how to use them. 56 | 57 | ### Multi-column environments 58 | 59 | Multi-column environments are supported via's Pandoc's [fenced_divs](https://pandoc.org/MANUAL.html#extension-fenced_divs) syntax and some preamble sugar (bundled together with the template). For example, a two-column section would look like this. 60 | 61 | :::::: {.columns} 62 | ::: {.column width="48%" data-latex="{0.48\textwidth}"} 63 | Here is some example **dplyr** code. 64 | 65 | ```{r dplyr, message=FALSE} 66 | library(dplyr) 67 | 68 | mtcars %>% 69 | group_by(am) %>% 70 | summarise(mean(mpg)) 71 | ``` 72 | ::: 73 | 74 | ::: {.column width="4%" data-latex="{0.04\textwidth}"} 75 | \ 76 | ::: 77 | 78 | ::: {.column width="48%" data-latex="{0.48\textwidth}"} 79 | And the **data.table** equivalent. 80 | 81 | ```{r dt, message=FALSE} 82 | library(data.table) 83 | 84 | mtcars_dt = as.data.table(mtcars) 85 | mtcars_dt[, mean(mpg), by = am] 86 | ``` 87 | ::: 88 | :::::: 89 | \ 90 | 91 | The same idea can be extended to additional columns and the individual column widths are also adjustable. 92 | 93 | ### Regression tables 94 | 95 | I have fairly strong preferences about how regression tables should look (threeparttable FTW). Luckily, the fantastic **modelsummary** package has us covered for nice looking regression tables, particularly since it automatically supports different Rmd output formats and backends. (For example, via the equally excellent **kableExtra** package.) This makes it easy to produce regression tables that look good in both HTML and PDF... although the latter requires that the corresponding LaTeX packages be loaded first. This template loads those LaTeX packages automatically, so tables like the below Just Work^TM^. 96 | 97 | ```{r msummary, message=FALSE, warning=FALSE} 98 | library(modelsummary) 99 | library(kableExtra) 100 | 101 | mod = lm(mpg ~ vs * wt, mtcars) 102 | 103 | msummary( 104 | mod, 105 | vcov = list("iid", "hc1", "hc2", "hc3", ~cyl), ## Multiple SEs for our model 106 | stars = TRUE, 107 | gof_omit = "^(?!Std)" ## Optional 108 | ) %>% 109 | add_footnote( 110 | c("Wow, look at all those standard errors!", 111 | paste("This next footnote is pretty long. In fact, it runs over several", 112 | "lines of standard PDF output. Luckily that's no problem thanks to", 113 | "modelsummary, kableExtra, and threeparttable.") 114 | ), 115 | threeparttable = TRUE 116 | ) %>% 117 | kable_styling( 118 | latex_options = "hold_position", ## (Optional) Print table directly below code 119 | position = "center" ## (Optional) Center table 120 | ) 121 | ``` 122 | 123 | ### PDF support for non-standard fonts 124 | 125 | This is an easy one; simply a matter of adding `dev: cairo_pdf` to the YAML. But it's nice not having to remember that every time, no? 126 | 127 | *Note: As the figure caption suggests, to run this next chunk you'll need to add [Arial Narrow](https://docs.microsoft.com/en-us/typography/font-list/arial-narrow) to your font book if it's not installed on your system already.* 128 | 129 | ```{r mpg, message=FALSE} 130 | library(ggplot2) 131 | library(hrbrthemes) 132 | 133 | ggplot(mtcars, aes(mpg, wt)) + 134 | geom_point() + 135 | labs(x = "Fuel efficiency (mpg)", y = "Weight (tons)", 136 | title = "This plot uses Arial Narrow fonts", 137 | caption = "Note: Fonts must be installed separately on your system.") + 138 | theme_ipsum() 139 | ``` 140 | 141 | ### Ignore interactive content when exporting to PDF 142 | 143 | In general, this template tries to do a good job of automatically handling (i.e. ignoring) interactive content when exporting to PDF. A notable exception is with embedded interactive content like external GIFs. In this case, rather than typing the usual, say, `![](mind-blown.gif)` directly in the Rmd file, you should include the figure with `knitr::include_graphics` in an R chunk. This will allow you to control whether it renders, conditional on output format. For example, the following chunk will render an actual GIF when the knit target is HTML format, versus a message when that target is PDF format. 144 | 145 | ```{r gif_example, echo = FALSE, out.width='100%'} 146 | my_gif = 'https://github.com/grantmcdermott/lecturenotes/blob/master/man/figures/mind-blown.gif?raw=true' 147 | if (knitr::is_html_output()){ 148 | knitr::include_graphics(my_gif) 149 | } else { 150 | message("Sorry, this GIF is only available in the the HTML version of the notes.") 151 | } 152 | ``` 153 | -------------------------------------------------------------------------------- /inst/rmarkdown/templates/lecturenotes/skeleton/tex/mytemplate.tex: -------------------------------------------------------------------------------- 1 | % Options for packages loaded elsewhere 2 | \PassOptionsToPackage{unicode$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref} 3 | \PassOptionsToPackage{hyphens}{url} 4 | $if(colorlinks)$ 5 | \PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor} 6 | $endif$ 7 | $if(dir)$ 8 | $if(latex-dir-rtl)$ 9 | \PassOptionsToPackage{RTLdocument}{bidi} 10 | $endif$ 11 | $endif$ 12 | $if(CJKmainfont)$ 13 | \PassOptionsToPackage{space}{xeCJK} 14 | $endif$ 15 | % 16 | \documentclass[ 17 | $if(fontsize)$ 18 | $fontsize$, 19 | $endif$ 20 | $if(lang)$ 21 | $babel-lang$, 22 | $endif$ 23 | $if(papersize)$ 24 | $papersize$paper, 25 | $endif$ 26 | $if(beamer)$ 27 | ignorenonframetext, 28 | $if(handout)$ 29 | handout, 30 | $endif$ 31 | $if(aspectratio)$ 32 | aspectratio=$aspectratio$, 33 | $endif$ 34 | $endif$ 35 | $for(classoption)$ 36 | $classoption$$sep$, 37 | $endfor$ 38 | ]{$documentclass$} 39 | $if(beamer)$ 40 | $if(background-image)$ 41 | \usebackgroundtemplate{% 42 | \includegraphics[width=\paperwidth]{$background-image$}% 43 | } 44 | $endif$ 45 | \usepackage{pgfpages} 46 | \setbeamertemplate{caption}[numbered] 47 | \setbeamertemplate{caption label separator}{: } 48 | \setbeamercolor{caption name}{fg=normal text.fg} 49 | \beamertemplatenavigationsymbols$if(navigation)$$navigation$$else$empty$endif$ 50 | $for(beameroption)$ 51 | \setbeameroption{$beameroption$} 52 | $endfor$ 53 | % Prevent slide breaks in the middle of a paragraph 54 | \widowpenalties 1 10000 55 | \raggedbottom 56 | $if(section-titles)$ 57 | \setbeamertemplate{part page}{ 58 | \centering 59 | \begin{beamercolorbox}[sep=16pt,center]{part title} 60 | \usebeamerfont{part title}\insertpart\par 61 | \end{beamercolorbox} 62 | } 63 | \setbeamertemplate{section page}{ 64 | \centering 65 | \begin{beamercolorbox}[sep=12pt,center]{part title} 66 | \usebeamerfont{section title}\insertsection\par 67 | \end{beamercolorbox} 68 | } 69 | \setbeamertemplate{subsection page}{ 70 | \centering 71 | \begin{beamercolorbox}[sep=8pt,center]{part title} 72 | \usebeamerfont{subsection title}\insertsubsection\par 73 | \end{beamercolorbox} 74 | } 75 | \AtBeginPart{ 76 | \frame{\partpage} 77 | } 78 | \AtBeginSection{ 79 | \ifbibliography 80 | \else 81 | \frame{\sectionpage} 82 | \fi 83 | } 84 | \AtBeginSubsection{ 85 | \frame{\subsectionpage} 86 | } 87 | $endif$ 88 | $endif$ 89 | $if(beamerarticle)$ 90 | \usepackage{beamerarticle} % needs to be loaded first 91 | $endif$ 92 | $if(fontfamily)$ 93 | \usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$} 94 | $else$ 95 | \usepackage{lmodern} 96 | $endif$ 97 | $if(linestretch)$ 98 | \usepackage{setspace} 99 | $endif$ 100 | \usepackage{amssymb,amsmath} 101 | \usepackage{ifxetex,ifluatex} 102 | \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex 103 | \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc} 104 | \usepackage[utf8]{inputenc} 105 | \usepackage{textcomp} % provide euro and other symbols 106 | \else % if luatex or xetex 107 | $if(mathspec)$ 108 | \ifxetex 109 | \usepackage{mathspec} 110 | \else 111 | \usepackage{unicode-math} 112 | \fi 113 | $else$ 114 | \usepackage{unicode-math} 115 | $endif$ 116 | \defaultfontfeatures{Scale=MatchLowercase} 117 | \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} 118 | $if(mainfont)$ 119 | \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$} 120 | $endif$ 121 | $if(sansfont)$ 122 | \setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$} 123 | $endif$ 124 | $if(monofont)$ 125 | \setmonofont[$for(monofontoptions)$$monofontoptions$$sep$,$endfor$]{$monofont$} 126 | $endif$ 127 | $for(fontfamilies)$ 128 | \newfontfamily{$fontfamilies.name$}[$for(fontfamilies.options)$$fontfamilies.options$$sep$,$endfor$]{$fontfamilies.font$} 129 | $endfor$ 130 | $if(mathfont)$ 131 | $if(mathspec)$ 132 | \ifxetex 133 | \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} 134 | \else 135 | \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} 136 | \fi 137 | $else$ 138 | \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} 139 | $endif$ 140 | $endif$ 141 | $if(CJKmainfont)$ 142 | \ifxetex 143 | \usepackage{xeCJK} 144 | \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$} 145 | \fi 146 | $endif$ 147 | $if(luatexjapresetoptions)$ 148 | \ifluatex 149 | \usepackage[$for(luatexjapresetoptions)$$luatexjapresetoptions$$sep$,$endfor$]{luatexja-preset} 150 | \fi 151 | $endif$ 152 | $if(CJKmainfont)$ 153 | \ifluatex 154 | \usepackage[$for(luatexjafontspecoptions)$$luatexjafontspecoptions$$sep$,$endfor$]{luatexja-fontspec} 155 | \setmainjfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$} 156 | \fi 157 | $endif$ 158 | \fi 159 | $if(beamer)$ 160 | $if(theme)$ 161 | \usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$} 162 | $endif$ 163 | $if(colortheme)$ 164 | \usecolortheme{$colortheme$} 165 | $endif$ 166 | $if(fonttheme)$ 167 | \usefonttheme{$fonttheme$} 168 | $endif$ 169 | $if(mainfont)$ 170 | \usefonttheme{serif} % use mainfont rather than sansfont for slide text 171 | $endif$ 172 | $if(innertheme)$ 173 | \useinnertheme{$innertheme$} 174 | $endif$ 175 | $if(outertheme)$ 176 | \useoutertheme{$outertheme$} 177 | $endif$ 178 | $endif$ 179 | % Use upquote if available, for straight quotes in verbatim environments 180 | \IfFileExists{upquote.sty}{\usepackage{upquote}}{} 181 | \IfFileExists{microtype.sty}{% use microtype if available 182 | \usepackage[$for(microtypeoptions)$$microtypeoptions$$sep$,$endfor$]{microtype} 183 | \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts 184 | }{} 185 | $if(indent)$ 186 | $else$ 187 | \makeatletter 188 | \@ifundefined{KOMAClassName}{% if non-KOMA class 189 | \IfFileExists{parskip.sty}{% 190 | \usepackage{parskip} 191 | }{% else 192 | \setlength{\parindent}{0pt} 193 | \setlength{\parskip}{6pt plus 2pt minus 1pt}} 194 | }{% if KOMA class 195 | \KOMAoptions{parskip=half}} 196 | \makeatother 197 | $endif$ 198 | $if(verbatim-in-note)$ 199 | \usepackage{fancyvrb} 200 | $endif$ 201 | \usepackage{xcolor} 202 | \IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available 203 | \IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}} 204 | \hypersetup{ 205 | $if(title-meta)$ 206 | pdftitle={$title-meta$}, 207 | $endif$ 208 | $if(author-meta)$ 209 | pdfauthor={$author-meta$}, 210 | $endif$ 211 | $if(lang)$ 212 | pdflang={$lang$}, 213 | $endif$ 214 | $if(subject)$ 215 | pdfsubject={$subject$}, 216 | $endif$ 217 | $if(keywords)$ 218 | pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$}, 219 | $endif$ 220 | $if(colorlinks)$ 221 | colorlinks=true, 222 | linkcolor=$if(linkcolor)$$linkcolor$$else$Maroon$endif$, 223 | filecolor=$if(filecolor)$$filecolor$$else$Maroon$endif$, 224 | citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$, 225 | urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$, 226 | $else$ 227 | hidelinks, 228 | $endif$ 229 | pdfcreator={LaTeX via pandoc}} 230 | \urlstyle{same} % disable monospaced font for URLs 231 | $if(verbatim-in-note)$ 232 | \VerbatimFootnotes % allow verbatim text in footnotes 233 | $endif$ 234 | $if(geometry)$ 235 | $if(beamer)$ 236 | \geometry{$for(geometry)$$geometry$$sep$,$endfor$} 237 | $else$ 238 | \usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry} 239 | $endif$ 240 | $endif$ 241 | $if(beamer)$ 242 | \newif\ifbibliography 243 | $endif$ 244 | $if(listings)$ 245 | \usepackage{listings} 246 | \newcommand{\passthrough}[1]{#1} 247 | \lstset{defaultdialect=[5.3]Lua} 248 | \lstset{defaultdialect=[x86masm]Assembler} 249 | $endif$ 250 | $if(lhs)$ 251 | \lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{} 252 | $endif$ 253 | $if(highlighting-macros)$ 254 | $highlighting-macros$ 255 | $endif$ 256 | $if(tables)$ 257 | \usepackage{longtable,booktabs} 258 | $if(beamer)$ 259 | \usepackage{caption} 260 | % Make caption package work with longtable 261 | \makeatletter 262 | \def\fnum@table{\tablename~\thetable} 263 | \makeatother 264 | $else$ 265 | % Correct order of tables after \paragraph or \subparagraph 266 | \usepackage{etoolbox} 267 | \makeatletter 268 | \patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{} 269 | \makeatother 270 | % Allow footnotes in longtable head/foot 271 | \IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}} 272 | \makesavenoteenv{longtable} 273 | $endif$ 274 | $endif$ 275 | $if(graphics)$ 276 | \usepackage{graphicx} 277 | \makeatletter 278 | \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi} 279 | \def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi} 280 | \makeatother 281 | % Scale images if necessary, so that they will not overflow the page 282 | % margins by default, and it is still possible to overwrite the defaults 283 | % using explicit options in \includegraphics[width, height, ...]{} 284 | \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio} 285 | % Set default figure placement to htbp 286 | \makeatletter 287 | \def\fps@figure{htbp} 288 | \makeatother 289 | $endif$ 290 | $if(links-as-notes)$ 291 | % Make links footnotes instead of hotlinks: 292 | \DeclareRobustCommand{\href}[2]{#2\footnote{\url{#1}}} 293 | $endif$ 294 | $if(strikeout)$ 295 | \usepackage[normalem]{ulem} 296 | % Avoid problems with \sout in headers with hyperref 297 | \pdfstringdefDisableCommands{\renewcommand{\sout}{}} 298 | $endif$ 299 | \setlength{\emergencystretch}{3em} % prevent overfull lines 300 | \providecommand{\tightlist}{% 301 | \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} 302 | $if(numbersections)$ 303 | \setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$} 304 | $else$ 305 | \setcounter{secnumdepth}{-\maxdimen} % remove section numbering 306 | $endif$ 307 | $if(beamer)$ 308 | $else$ 309 | $if(block-headings)$ 310 | % Make \paragraph and \subparagraph free-standing 311 | \ifx\paragraph\undefined\else 312 | \let\oldparagraph\paragraph 313 | \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}} 314 | \fi 315 | \ifx\subparagraph\undefined\else 316 | \let\oldsubparagraph\subparagraph 317 | \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} 318 | \fi 319 | $endif$ 320 | $endif$ 321 | $if(pagestyle)$ 322 | \pagestyle{$pagestyle$} 323 | $endif$ 324 | $for(header-includes)$ 325 | $header-includes$ 326 | $endfor$ 327 | $if(lang)$ 328 | \ifxetex 329 | % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic) 330 | \usepackage{polyglossia} 331 | \setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$} 332 | $for(polyglossia-otherlangs)$ 333 | \setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$} 334 | $endfor$ 335 | \else 336 | \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel} 337 | $if(babel-newcommands)$ 338 | $babel-newcommands$ 339 | $endif$ 340 | \fi 341 | $endif$ 342 | $if(dir)$ 343 | \ifxetex 344 | % Load bidi as late as possible as it modifies e.g. graphicx 345 | \usepackage{bidi} 346 | \fi 347 | \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex 348 | \TeXXeTstate=1 349 | \newcommand{\RL}[1]{\beginR #1\endR} 350 | \newcommand{\LR}[1]{\beginL #1\endL} 351 | \newenvironment{RTL}{\beginR}{\endR} 352 | \newenvironment{LTR}{\beginL}{\endL} 353 | \fi 354 | $endif$ 355 | $if(natbib)$ 356 | \usepackage[$natbiboptions$]{natbib} 357 | \bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$} 358 | $endif$ 359 | $if(biblatex)$ 360 | \usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex} 361 | $for(bibliography)$ 362 | \addbibresource{$bibliography$} 363 | $endfor$ 364 | $endif$ 365 | $if(csl-refs)$ 366 | \newlength{\cslhangindent} 367 | \setlength{\cslhangindent}{1.5em} 368 | \newenvironment{cslreferences}% 369 | {$if(csl-hanging-indent)$\setlength{\parindent}{0pt}% 370 | \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces$endif$}% 371 | {\par} 372 | $endif$ 373 | 374 | $if(title)$ 375 | \title{$title$$if(thanks)$\thanks{$thanks$}$endif$} 376 | $endif$ 377 | $if(subtitle)$ 378 | $if(beamer)$ 379 | $else$ 380 | \usepackage{etoolbox} 381 | \makeatletter 382 | \providecommand{\subtitle}[1]{% add subtitle to \maketitle 383 | \apptocmd{\@title}{\par {\large #1 \par}}{}{} 384 | } 385 | \makeatother 386 | $endif$ 387 | \subtitle{$subtitle$} 388 | $endif$ 389 | \usepackage{authblk} 390 | $for(author)$ 391 | $if(author.name)$ 392 | $if(author.number)$ 393 | \author[$author.number$]{$author.name$} 394 | $else$ 395 | \author[]{$author.name$} 396 | $endif$ 397 | $if(author.affiliation)$ 398 | $if(author.email)$ 399 | \affil{$author.affiliation$ \thanks{$author.email$}} 400 | $else$ 401 | \affil{$author.affiliation$} 402 | $endif$ 403 | $endif$ 404 | $else$ 405 | \author{$author$} 406 | $endif$ 407 | $endfor$ 408 | \date{$date$} 409 | $if(beamer)$ 410 | $if(institute)$ 411 | \institute{$for(institute)$$institute$$sep$ \and $endfor$} 412 | $endif$ 413 | $if(titlegraphic)$ 414 | \titlegraphic{\includegraphics{$titlegraphic$}} 415 | $endif$ 416 | $if(logo)$ 417 | \logo{\includegraphics{$logo$}} 418 | $endif$ 419 | $endif$ 420 | 421 | \begin{document} 422 | $if(has-frontmatter)$ 423 | \frontmatter 424 | $endif$ 425 | $if(title)$ 426 | $if(beamer)$ 427 | \frame{\titlepage} 428 | $else$ 429 | \maketitle 430 | $endif$ 431 | $if(abstract)$ 432 | \begin{abstract} 433 | $abstract$ 434 | \end{abstract} 435 | $endif$ 436 | $endif$ 437 | 438 | $for(include-before)$ 439 | $include-before$ 440 | 441 | $endfor$ 442 | $if(toc)$ 443 | $if(toc-title)$ 444 | \renewcommand*\contentsname{$toc-title$} 445 | $endif$ 446 | $if(beamer)$ 447 | \begin{frame}[allowframebreaks] 448 | $if(toc-title)$ 449 | \frametitle{$toc-title$} 450 | $endif$ 451 | \tableofcontents[hideallsubsections] 452 | \end{frame} 453 | $else$ 454 | { 455 | $if(colorlinks)$ 456 | \hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$$endif$} 457 | $endif$ 458 | \setcounter{tocdepth}{$toc-depth$} 459 | \tableofcontents 460 | } 461 | $endif$ 462 | $endif$ 463 | $if(lot)$ 464 | \listoftables 465 | $endif$ 466 | $if(lof)$ 467 | \listoffigures 468 | $endif$ 469 | $if(linestretch)$ 470 | \setstretch{$linestretch$} 471 | $endif$ 472 | $if(has-frontmatter)$ 473 | \mainmatter 474 | $endif$ 475 | $body$ 476 | 477 | $if(has-frontmatter)$ 478 | \backmatter 479 | $endif$ 480 | $if(natbib)$ 481 | $if(bibliography)$ 482 | $if(biblio-title)$ 483 | $if(has-chapters)$ 484 | \renewcommand\bibname{$biblio-title$} 485 | $else$ 486 | \renewcommand\refname{$biblio-title$} 487 | $endif$ 488 | $endif$ 489 | $if(beamer)$ 490 | \begin{frame}[allowframebreaks]{$biblio-title$} 491 | \bibliographytrue 492 | $endif$ 493 | \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$} 494 | $if(beamer)$ 495 | \end{frame} 496 | $endif$ 497 | 498 | $endif$ 499 | $endif$ 500 | $if(biblatex)$ 501 | $if(beamer)$ 502 | \begin{frame}[allowframebreaks]{$biblio-title$} 503 | \bibliographytrue 504 | \printbibliography[heading=none] 505 | \end{frame} 506 | $else$ 507 | \printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$ 508 | $endif$ 509 | 510 | $endif$ 511 | $for(include-after)$ 512 | $include-after$ 513 | 514 | $endfor$ 515 | \end{document} 516 | -------------------------------------------------------------------------------- /inst/rmarkdown/templates/lecturenotes/skeleton/tex/preamble.tex: -------------------------------------------------------------------------------- 1 | %% See: https://bookdown.org/yihui/rmarkdown-cookbook/multi-column.html 2 | %% I've made some additional adjustments based on my own preferences (e.g. cols 3 | %% should be top-aligned in case of uneven vertical length) 4 | \newenvironment{columns}[1][]{}{} 5 | 6 | \newenvironment{column}[1]{\begin{minipage}[t]{#1}\ignorespaces}{% 7 | \end{minipage} 8 | \ifhmode\unskip\fi 9 | \aftergroup\useignorespacesandallpars 10 | } 11 | 12 | \def\useignorespacesandallpars#1\ignorespaces\fi{% 13 | #1\fi\ignorespacesandallpars} 14 | 15 | \makeatletter 16 | \def\ignorespacesandallpars{% 17 | \@ifnextchar\par 18 | {\expandafter\ignorespacesandallpars\@gobble}% 19 | {}% 20 | } 21 | \makeatother 22 | -------------------------------------------------------------------------------- /inst/rmarkdown/templates/lecturenotes/template.yaml: -------------------------------------------------------------------------------- 1 | name: Lecture Notes 2 | description: > 3 | My Rmd lecture notes setup, designed for exporting to both HTML and PDF 4 | formats. Takes care of things like consistent multi-column environments and 5 | regression table output, support for non-standard fonts in figures, nice 6 | affiliation typesetting for PDF format, etc. 7 | create_dir: FALSE 8 | -------------------------------------------------------------------------------- /lecturenotes.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | -------------------------------------------------------------------------------- /man/figures/mind-blown.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grantmcdermott/lecturenotes/fc36575acc56915c02b99d03aa268ea65d2cf49b/man/figures/mind-blown.gif -------------------------------------------------------------------------------- /pkgdown/extra.css: -------------------------------------------------------------------------------- 1 | /* pkgdown/extra.css */ 2 | .row > main { 3 | max-width: 75%; 4 | } 5 | 6 | @media 7 | (min-width: 1400px) { 8 | main + .col-md-3 { 9 | margin-left: unset; 10 | padding-left: 5rem; 11 | } 12 | } 13 | --------------------------------------------------------------------------------