Insert a logo in upper right corner of R markdown pdf document
Ok, I have found the solution:
---
title:
header-includes:
\usepackage{graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setlength\headheight{28pt}
\fancyhead[L]{\includegraphics[width=5cm]{GPIM_Logo_300x85.png}}
\fancyfoot[LE,RO]{GPIM}
output: pdf_document
---
You can use the includes
option in the yaml to specify a custom addition to your latex header. The yaml part would look like
---
output:
pdf_document:
keep_tex: true
includes:
in_header: header.tex
---
and you need to save a separate file called header.tex
with the following defining your company logo like so:
\usepackage{fancyhdr}
\pagestyle{fancy}
\rhead{\includegraphics[width = .05\textwidth]{logo.png}}
Here I used the fancyhdr
latex package to add the logo, but there are other potential solutions. See here for more options.