Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YAML front matter in R markdown version 2: add an institution and logo

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
---
like image 919
Joanne Demmler Avatar asked Oct 13 '14 10:10

Joanne Demmler


People also ask

How do I add YAML front matter?

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.

How do I add a logo to Markdown?

You can add images to Markdown using the [alt text](image_url) syntax.

How do I add a title in Rmarkdown?

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.

What is YAML in 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.


1 Answers

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

like image 199
Joanne Demmler Avatar answered Oct 22 '22 14:10

Joanne Demmler