How to add an image as a header/footer in Markdown

2020-03-01 18:26发布

问题:

I want to add images as headers and footers (in keeping with my organizations visual identity) to PDF reports. I've managed to do it in Sweave but I'd also like to be able to do it using just Markdown. I can insert the image using ![footer](H:/R/Footer.pdf) however when I try to use the wallpaper package (like I do in Sweave) I get an error.

---
title: "2014 Report"
author: "My Name"
date: "Monday, October 06, 2014"
output:
  pdf_document:
    number_sections: yes
    toc: yes
fontsize: 10pt
header-includes:
    - \usepackage{wallpaper}
abstract: This is my abstract
---
\LRCornerWallPaper{0.99}{![footer](H:/R/Footer.pdf)} 

Is there a way in Markdown, or do I need to stick to Sweave?

回答1:

The correct usage of the wallpaper package in this case would be simply

\LRCornerWallPaper{0.99}{path/to/pic}


回答2:

---
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \setlength\headheight{45pt}
- \fancyhead{\includegraphics{header.jpg}}
- \setlength\footskip{5pt}
- \fancyfoot{\includegraphics{footer.jpg}}
output: 
  pdf_document:
   fig_caption: false

---


标签: r markdown knitr