在标题中插入换行符

时间:2015-03-19 18:14:36

标签: r knitr r-markdown

如何在rmarkdown文档的标题中插入换行符? 这不起作用:

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

1 个答案:

答案 0 :(得分:17)

使用管道

  

YAML中行末尾的管道符号表示后面的任何缩进文本都应解释为多行标量值。请参阅the YAML spec

     

具体来说,管道表明(缩进除外)标量值应以字面方式解释,以保留换行符。相反,>字符表示跟随多行“折叠”标量,这意味着换行符将转换为空格。

what is the use of pipe symbol in yaml

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

enter image description here

这是重复但我找不到原文。

编辑:这是!

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