将标题拆分为多行?

问题描述 投票:0回答:4

在 R markdown 文档(html 和演示文稿)中,是否可以手动将标题拆分为多行?我尝试玩管道,它产生了可怕的输出。

---
title:  'A title I want to split on two lines'
author: 
date: 
output:
  ioslides_presentation
---
r yaml rstudio markdown r-markdown
4个回答
29
投票

添加摘要的示例展示了管道的使用 |换行并包含段落。这也适用于标题和其他 yaml 元素。对于摘要或标题:

---
abstract: |
    What works for the abstract.

    Works for the title, too!
title: |
    | title 
    | subtitle
output: pdf_document 
---

27
投票

对于 HTML 输出,只需使用

<br>
标签,而如果您的输出是 PDF 或 PDF 演示文稿,则由
\\
给出的用于换行的标准 LaTeX 代码应该可以工作。

示例

---
title:  'A title I want to <br> split on two lines'
author: 
date: 
output:
  ioslides_presentation
---

对于 PDF

为了排除可能性,我尝试放置

\\
\newline
,两者都不会拆分,所以对于 PDF 来说似乎有点棘手。
\linebreak
停止 knitr 解析。也许另一个用户可以解决 knitr PDF 的这个问题。


25
投票

对于 PDF 输出,实验表明以下方法有效:

---
title:  'A title I want to  \nsplit on two lines'
author: 
date: 
output: pdf_document
---

即两个空格后跟

\n


-1
投票

使用

\\linebreak
进行 pdf 输出。

© www.soinside.com 2019 - 2024. All rights reserved.