Split title in two lines in Rmarkdown for word output

百般思念 提交于 2020-01-03 17:47:29

问题


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.


回答1:


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

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



来源:https://stackoverflow.com/questions/51559106/split-title-in-two-lines-in-rmarkdown-for-word-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!