How to add line break in Rmarkdown Word title using paste()?

247 Views Asked by At

I want to make a Word file using , and the title needs to be broken into 2 parts. Since the title is dynamic, I paste() the two pieces together.

This works:

---
title: "part 1  \n part 2"
output: word_document
---

But this does not work:

---
title: '`r paste("part 1", "part 2", sep = "  \\n ")`'
output: word_document
---

Any help would be much appreciated.

1

There are 1 best solutions below

0
On

In the meantime, I found a solution myself. Not very clean, but it does the trick:

---
output: word_document
---

<div custom-style="Title">
part `r 1`
</div>

<div custom-style="Title">
part `r 2`
</div>

(this of course requires that in your Word template, there is a style called 'Title')