Michael
Michael

Reputation: 5898

Insert a linebreak in title

How do I insert a linebreak in the title of an rmarkdown document? This does not work:

---
title: "title \break subtitle"
output: pdf_document 
---`

Upvotes: 16

Views: 9950

Answers (1)

rawr
rawr

Reputation: 20811

Use pipes

The pipe symbol at the end of a line in YAML signifies that any indented text that follows should be interpreted as a multi-line scalar value. See the YAML spec.

Specifically, the pipe indicates that (except for the indentation) the scalar value should be interpreted literally in such a way that preserves newlines. Conversely, the > character indicates that multi-line "folded" scalar follows, meaning that newlines are converted to spaces.

what is the use of pipe symbol in yaml

---
title: |
    | title 
    | subtitle
output: pdf_document 
---

enter image description here

This is a duplicate but I can't find the original.

edit: here it is!

How can I force a line break in rmarkdown's title?

Upvotes: 30

Related Questions