Jon Nagra
Jon Nagra

Reputation: 1660

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

I have a quite long title in a rmarkdown document and I would like to force a line break in a specific position.

Minimum example:

---
title: "Quite long title want the * line break at the asterisk"
output: html_document
---

I have tried: \n, \newline, \\ and a manual line break. None of them seem to work.

I believe it has to be quite straightforward but I haven't been able to find a solution.

Upvotes: 70

Views: 40251

Answers (4)

user7351278
user7351278

Reputation: 1

i cannot comment on the chosen answer. The preferred solution makes a warning appear as it creates a table inside the title. A correct approach for multiline titles should be the following:

---
title: |
    Quite long title want the
    line break at the asterisk

output: html_document
---

Upvotes: 0

Bartimus
Bartimus

Reputation: 140

I know that this is an old post, but I wanted to chime in with:

# A Title of some kind
<br><br><br><br><br>  

# Another title that has 5 blank lines above it

Note that you need 2 spaces on line 3 or the title will not display properly in Rmarkdown::html_document. This solution is a little hard to find, hope it helps!

Upvotes: 4

filups21
filups21

Reputation: 1917

For a centered, multi-line title:

---
title: |
  <center> Veryyyyyyy </center>
  <center> yyyyyyyyyyyyyy Looooo </center>
  <center> oooooooooooooooo </center>
  <center> oooooooooooong </center>

author: "Foo Bar"
date: "6 March 2015"
output: html_document
---

enter image description here

Upvotes: 25

Peter Diakumis
Peter Diakumis

Reputation: 4042

Try using a pipe | in each line:

---
title: |
  | Veryyyyyyy  
  | yyyyyyyyyyyyyy Looooo  
  | oooooooooooooooo
  | oooooooooooong 

author: "Foo Bar"
date: "6 March 2015"
output: html_document
---

enter image description here

Upvotes: 117

Related Questions