Outlander
Outlander

Reputation: 583

Split title in two lines in Rmarkdown for word output

I have seen various solutions around which work for pdf and HTML document output. However, none worked for me for word output. When used | as suggested here: Split the title onto multiple lines? simply made the whole title disappear. Here is the code:

---  
title: |
    | Supporting Information
    | Development and mechanistic bla bla.
author: Some people
output:
  word_document:
    reference_docx: ACS SI style for RMD.docx
mainfont: Arial
---
<style>
body {
text-align: justify}
 p {line-height: 1.5em;}
</style>

Any help would be much appreciated.

Upvotes: 9

Views: 4831

Answers (1)

jay.sf
jay.sf

Reputation: 73702

The | pipes do not work together with word. Set the title into "" instead. For a line wrap in the title with output to word we can use:

  \n

(important: headed by two spaces!).

---  
title: "Supporting Information  \nDevelopment and mechanistic bla bla."
author: Some people
output: word_document
---

Yielding

enter image description here

Empty lines

To achieve empty lines within the title word wants "something" in these lines, so we can set a non-breaking space after the line breaking code:

  \n &nbsp;

(important again: \n headed by two spaces!).

---  
title: "Supporting Information  \n &nbsp;  \n Development and mechanistic bla bla."
author: Some people
output: word_document
---

Yielding

enter image description here

Upvotes: 13

Related Questions