Stop knitr "sanitizing" characters in header-includes
You can (and should) use the includes
option (see documentation). An extra benefit is that your LaTeX code will only be applied to the LaTeX output. If you use header-includes
in the YAML metadata, it will be applied to all possible output formats, e.g. even when you compile Rmd to HTML.
BTW, knitr does not sanitize any characters in YAML. Pandoc does.