I have a long .txt file that contains packages and settings that I want to used in my Rmarkdown file. I also want to add statements to the header, based on the output of R calculations. In this particular case I want to add a titlegraphic that is located in another directory, like this:
working directory
|--- reports
|----| my_report.Rmd
|--- www
|----| image.png
So the header of the Rmarkdown file would look like:
output:
beamer_presentation:
keep_tex: true
includes:
in_header: header.txt
header-includes:
- \titlegraphic{\includegraphics[width=0.3\paperwidth]{`r paste0("dirname(getwd()),"image.png")`}}
If only one of the statements is included (in_header or header-includes), they work fine. But when I use them both, the content of header-includes seems to be overwritten. An example is given in the files below, where upon inspecting the resulting .tex file, I find that \usepackage{fancyhdr} is in the header, but there is no mention of the `\titlegraphic' expression.
header.txt
\usepackage{fancyhdr}
example.Rmd
title: Example 1
output:
beamer_presentation:
keep_tex: true
includes:
in_header: header.txt
header-includes:
\titlegraphic{\includegraphics[width=0.3\paperwidth]{`r paste0("just_an_example_","logo.png")`}}
---
### This is a test