R Markdown
Common YAML options
# Date that automatically updates
date: "`r format(Sys.time(), '%B %d, %Y')`"
output:
pdf_document:
keep_tex: TRUE # Keep the latex file
number_sections: TRUE
Common Setup options
Reasonable for reports
```{r setup, include=FALSE}
knitr::opts_chunk$set(
echo = FALSE,
cache = FALSE,
warning = FALSE,
message = FALSE,
fig.align = "center",
)
# Tables
kable_standard <- function(...) {
kable(booktabs = TRUE, linesep = "", ...) %>%
kable_styling(full_width = FALSE)
}
options(knitr.kable.NA = '')
```
And easily change the font size by adding this directly to the document:
<style>
body{
font-size: 14pt;
}
</style>
Note that adding latex_options = c("hold_position") may be useful in holding tables to their current position. I wasn't able to get it to work. An alternative (but tedious) option is to add keep_tex: TRUE to the YAML (under pdf_document:) and manually add [!htbp] at the end of the \begin{figure} line in the .tex file.
Almost anything you'd want to do with a latex table can be found at:
- Create Awesome LaTeX Table with knitr::kable and kableExtra
- Create Awesome HTML Table with knitr::kable and kableExtra
Adding appendix to file
## Appendix: R Code
```{r appendix, ref.label=knitr::all_labels(),echo=TRUE,eval=FALSE}
```