7.2 Loading LaTeX Packages in R Markdown
If we only need a couple of LaTeX packages, we can add them one by one in the YAML header.5
--- title: "" output: pdf_document: extra_dependencies: ["amsmath", "color"] ---
To load a large number of packages more efficiently, try
--- title: "" subtitle: "" output: pdf_document: includes: in_header: ["TexPackages.tex", "TexMacros.tex"] latex_engine: xelatex ---
where
TexPackages.tex
has all packages, for example,\usepackages{amsmath} \usepackages{color}
and
TexMacros.tex
has all macros, such as\renewcommand{\Re}{\operatorname{Re}} \renewcommand{\Im}{\operatorname{Im}} \newcommand{\Arg}{\operatorname{Arg}}