R Markdown: How to add background colour to header and knit to PDF?

I’m wanting to add a background colour to my header in a document I’m knitting to PDF in R Markdown.

I’m hoping for the below result which I’ve just done up in PowerPoint as an example.

Desired End Result

This is my current YAML code that produces the below outcome.

---
title: >
    `\vspace{-1.8cm}`{=latex}
header-includes:
 - \usepackage{geometry} # Margins.
 - \geometry{margin=0.3in}
 - \usepackage[T1]{fontenc} # Document font.
 - \usepackage[default]{sourcesanspro}
 - \usepackage{fancyhdr}
 - \pagestyle{fancy}
 - \addtolength{\headheight}{2.5cm} # Header height.
 - \renewcommand{\headrulewidth}{0pt} # Remove line.
 - \usepackage{makecell}
 - \usepackage[export]{adjustbox}
 - \lhead{\includegraphics[valign=m, width=2cm]{r-studio-logo.png}}
 - \rhead{\LARGE\textbf{Main Title to go Here}\\\normalsize\textbf{Subitle to go Here}}
 - \fancypagestyle{plain}{\pagestyle{fancy}}
output: pdf_document
editor_options:
  chunk_output_type: console
---

Current Result

How can I edit my YAML code to add a black background to the entire height and width of the header section?

Read more here: Source link