Is it possible to add an institution and logo to the YAML front matter in R markdown version 2?
I'm looking for something like this
---
title: "My report"
author: "me"
institution: "Swansea University"
logo: "logo.png"
output:
pdf_document:
toc: yes
---
YAML frontmatters can be defined at the beginning of a file, by starting on the first line with three dashes ( --- ) and ending the frontmatter either with three dashes or three dots (the former variant is more common). They contain valid YAML and can be used to define arbitrary variables.
You can add images to Markdown using the [alt text](image_url) syntax.
Click the File tab, New File , then R Markdown . Leave the default output as is (HTML), choose a title for the new R Markdown file or leave it blank. The new document generated will already contain text - this will demonstrate the basics of R Markdown.
YAML header is a short blob of text, specially formatted with key: value pairs tags, that seats at the top of our Rmarkdown document. The header not only dictates the final file format, but a style and feel for our final document.
The answer is to use a template file, but it needs a bit of tweaking for the logo bit:
---
title: "My report"
author: "me"
output:
pdf_document:
toc: yes
includes:
in_header: style.tex
---
Prepare the document "style.tex" in the same folder as your markdown file and make sure you have changed you working directory in R to this folder.
Add the following lines to your "style.tex" file:
\institute{My institute}
\pgfdeclareimage[width=2cm]{logo}{logo.png}
\usebackgroundtemplate{\pgfuseimage{logo}}
Thanks to: Inserting logo into beamer presentation using R Markdown
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With