2.3 YAML Header

The top of an R Markdown document is called the YAML header (yet another markup language).

---
  title: "Untitled"
author: "Your Name Here"
date: "03 January, 2022"
output:
  pdf_document:
  latex_engine: xelatex
word_document:
  fig_height: 5
fig_width: 7
---

This is where you can specify:

  • Title
  • Author
  • Date
  • theme (html) or reference style document (Word)
  • Table of Contents options
  • figure default heights & widths
  • bibliography/csl files
  • … and lots of other things

Having your own *.Rmd template file with the options you most often use is helpful.

A simple example is available here and a more comprehensive example is here

The ymlthis package can help you to write more complicated YAML headers.