Section 6.3 Add logo to title page
We can use the titling LaTeX package to alter our title block to include an image. Below is a full example that shows how to add the R logo (
logo.jpg) to the title page. The image can be of any format that LaTeX supports (e.g., jpg, png, or pdf).
---
title: Adding a Logo to LaTeX Title
author: Michael Harper
date: December 7th, 2018
output: pdf_document
header-includes:
- \usepackage{titling}
- \pretitle{\begin{center}
\includegraphics[width=2in,height=2in]{logo.jpg}\LARGE\\}
- \posttitle{\end{center}}
---
An example output is shown in Figureย 6.3.1.

An alternative method that does not require a special LaTeX package (titling) is to just insert the image in the
title field using the Markdown syntax. For example:
title: |
{width=1in}
Adding a Logo to LaTeX Title
In this case, you will not need the
header-includes field in the YAML frontmatter in the first example. Please note that although you cannot see them, there are two trailing spaces after {width=1in}, which means a line break in Markdown (see Sectionย 4.12). Without the line break, the image and the title would be on the same line, which may not be what you desire.
