将空行添加到 Word 输出 RMarkdown

Add Blank Line to Word Output RMarkdown

美好的一天。

我正在尝试使用导出到 word 文档的 rmarkdown 文件创建会议摘要提交。我试图找到一种方法在输出的 word 文档中插入一个空行。我发现可以通过在降价文件末尾添加两个空格来插入换行符,但是,当您只需要一个空行时,这个技巧就不起作用了。下面是示例代码

  ---
title: "HERE IS THE TITLE OF MY ABSTRACT"
output:
  word_document:
    reference_docx: draft-styles.docx
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r, include=FALSE, cache=FALSE, echo=FALSE}
library(rmarkdown)
```


Authors: John H. Curry^1^, Kathy S. James^1^, Patrick S. Curry^1^
Affiliations: ^1^University of Somewhere 

*Presenting author information*  
Name: John H. Curry 
Email: curry@umed.edu  
Affiliation details: Kinesiology, University of Somewhere, Ottawa, Canada  


*Coauthor #2*  
Name: Kathy S. James  
Email: james@umed.edu 
Affiliation details: Kinesiology, University of Somewhere, Ottawa, Canada  

*Coauthor #3*  
Name: Patrick S. Curry 
Email: curry2@umed.edu  
Affiliation details: Kinesiology, University of Somewhere, Ottawa, Canada  


## Introduction
Here is where I write my introduction....

## Methods
Here is where I write my methods

## Results
Here is where I write my results...

## Discussion
Here is where I write my discussion

当我编织文档时,遗憾的是它有点成簇。下面我添加了一张图片,其中包含当前输出(左)和我希望它看起来像什么(右)。

我已经阅读了论坛,但在使用 word 文档时我还没有看到解决这个问题的方法。如果有任何建议,我将不胜感激。

谢谢

你可以在Rmd文件中使用\newline如下:

---
title: "HERE IS THE TITLE OF MY ABSTRACT"
output:
  word_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r, include=FALSE, cache=FALSE, echo=FALSE}
library(rmarkdown)
```


Authors: John H. Curry^1^, Kathy S. James^1^, Patrick S. Curry^1^
    Affiliations: ^1^University of Somewhere

\newline

*Presenting author information*
    Name: John H. Curry
Email: curry@umed.edu
Affiliation details: Kinesiology, University of Somewhere, Ottawa, Canada

\newline

*Coauthor #2*
Name: Kathy S. James
Email: james@umed.edu
Affiliation details: Kinesiology, University of Somewhere, Ottawa, Canada

\newline

*Coauthor #3*
Name: Patrick S. Curry
Email: curry2@umed.edu
Affiliation details: Kinesiology, University of Somewhere, Ottawa, Canada

\newline

## Introduction
Here is where I write my introduction....

\newline

## Methods
Here is where I write my methods

\newline

## Results
Here is where I write my results...

\newline

## Discussion
Here is where I write my discussion

万一你接下来要问,newpage稍微难一点。您需要在 word 中为标题 5(例如)创建一个新样式,它会自动在新页面上开始,并且在您的 Rmd 文件中,您将使用标题 5 作为新行。不过,网上有很多关于此的资源。

chinsoon12 给我一个答案。这是我用来获得所需输出的代码。我确实觉得我需要写 \newline \newline (而不是只放一次)有点奇怪。也不可能在一行代码的末尾添加 \newline 并获得相同的效果。您需要在 .rmd 文件中换行才能使其正常工作(至少从我的尝试来看是这样)。

---
title: "HERE IS THE TITLE OF MY ABSTRACT"
output:
  word_document:
    reference_docx: draft-styles.docx
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r, include=FALSE, cache=FALSE, echo=FALSE}
library(rmarkdown)
```


Authors: John H. Curry^1^, Kathy S. James^1^, Patrick S. Curry^1^ 

\newline

Affiliations: ^1^University of Michigan  

\newline  \newline

*Presenting author information*  
Name: John H. Curry  
Email: curry@umed.edu  
Affiliation details: Kinesiology, University of Somewhere, Ottawa, Canada  

\newline \newline

*Coauthor #2*  
Name: Kathy S. James  
Email: james@umed.edu   
Affiliation details: Kinesiology, University of Somewhere, Ottawa, Canada  

\newline \newline

*Coauthor #3*  
Name: Patrick S. Curry  
Email: curry2@umed.edu  
Affiliation details: Kinesiology, University of Somewhere, Ottawa, Canada  

\newline \newline

## Introduction
Here is where I write my introduction....

\newline \newline

## Methods
Here is where I write my methods

\newline \newline


## Results
Here is where I write my results...

\newline \newline

## Discussion
Here is where I write my discussion

\newline \newline

我在 2 年前对答案投了赞成票,但现在 \newline 对我不起作用。但是,<br> 有效。确保 <br> 上方和下方的 space 为空。也适用于图表和代码片段输出。

    ---
title: "Word/knitr linefeed test"
author: "E Krantz"
date: "7/28/2020"
output: word_document
---

Here are results with no assisted new line.

How to new line in knitr with MSWord? Test newline:

\newline  \newline

That doesn't work. Test br:
<br>
That does not work. Test br with linebreak after:
<br>

No changes. Test br with linebreak before:

<br>
This puts a space before this sentence. Test br with break before and after.

<br>

That works! Double br:

<br>
<br>

Same as single br. How about double br with a line break between each?

<br>

<br>

That works!

结果如下: