0

I try to put image file (logo.png) on the top of the first page of my document. I followed the guideline from here: Insert a logo in upper right corner of R markdown pdf document. However, the image still does not appear. My code is: I still don't know what's wrong with my codes. Thanks.

---
title: 'Theory'
date: "Fall 2021"
output:
  pdf_document:
    keep_tex: yes
    fig_caption: yes
    latex_engine: pdflatex
    template: Syllabus_template.tex
  html_document:
    df_print: paged
geometry: margin=1in

header-includes:        
- \usepackage{fancyhdr}       
- \usepackage{graphicx}       
- \usepackage{eurosym}   
- \usepackage{booktabs,xcolor}   
- \pagestyle{fancy}   
- \fancyhf{}   
- \addtolength{\headheight}{1.0cm}  
- \rhead{MainSky Stress Test Report - \today}   
- \lhead{\includegraphics[width=6cm]{/Users/jj/Documents/logo.png}}   
- \rfoot{Page \thepage} 
- \fancypagestyle{plain}{\pagestyle{fancy}} 



#Fill this in with any number of instructors. It uses a two column layout with a column break after each instructor.



# teachingassistant:
#  - name: Filler
#    email: filler@fill.com
#    officehours: W T
#    office: OfficeNumber
#    sections: '301'
   
classroom: 'Remote (either MS Teams or Zoom)'
fontsize: 11pt
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(timeDate)
library(tibble)
library(dplyr)
library(knitr)

#This code chunk sets up a table of meeting days for the course.
#You can set days of the week for course meetings (e.g. Monday and Wednesday).
#Semester start and end dates are selected and then university holidays like spring break are specified.

jck21
  • 751
  • 4
  • 16

1 Answers1

3

You can add an image to the title page like this:

---
title: 'Theory'
date: "Fall 2021"
output:
  pdf_document:
    keep_tex: yes
    fig_caption: yes
    latex_engine: pdflatex
    # template: Syllabus_template.tex
  html_document:
    df_print: paged
geometry: margin=1in

header-includes:        
- \usepackage{graphicx}       
- \usepackage{eurosym}   
- \usepackage{booktabs,xcolor}   
- \makeatletter\patchcmd{\@maketitle}{\begin{center}}{\begin{center}\includegraphics[width=3cm]{example-image-duck}\par}{}{}\makeatother




#Fill this in with any number of instructors. It uses a two column layout with a column break after each instructor.



# teachingassistant:
#  - name: Filler
#    email: filler@fill.com
#    officehours: W T
#    office: OfficeNumber
#    sections: '301'
   
classroom: 'Remote (either MS Teams or Zoom)'
fontsize: 11pt
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(timeDate)
library(tibble)
library(dplyr)
library(knitr)

#This code chunk sets up a table of meeting days for the course.
#You can set days of the week for course meetings (e.g. Monday and Wednesday).
#Semester start and end dates are selected and then university holidays like spring break are specified.

enter image description here