## 5.3 Include additional LaTeX packages

The use of additional LaTeX packages can allow for extensive customization of document styling. In addition, several packages such as kableExtra (Zhu 2019) may have LaTeX dependencies for the R package to function. Much like R, we need to load packages within the R Markdown document before we are able to use their functions.

We can load additional LaTeX packages using the extra_dependencies option within the pdf_document YAML settings. This allows us to provide a list of LaTeX packages to be loaded in the intermediate LaTeX output document, e.g.,

---
title: "Using more LaTeX packages"
output:
pdf_document:
extra_dependencies: ["bbm", "threeparttable"]
---

If you need to specify options when loading the package, you can add a second-level to the list and provide the options as a list, e.g.,

output:
pdf_document:
extra_dependencies:
caption: ["labelfont={bf}"]
lmodern: null

For those familiar with LaTeX, this is equivalent to the following LaTeX code:

\usepackage[labelfont={bf}]{caption}
\userpackage{lmodern}