Pat*_*ick 11 ms-word rstudio blank-line knitr r-markdown
美好的一天.
我正在尝试使用导出到word文档的rmarkdown文件创建会议摘要提交.我试图找到一种方法在输出的word文档中插入一个空行.我发现可以通过在markdown文件的末尾添加两个空格来插入换行符,但是,当你只想要一个空行时,这个技巧不起作用.下面是示例代码
---
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
Run Code Online (Sandbox Code Playgroud)
当我编织文件时,可悲的是它有点聚集.下面我添加了一张带有当前输出的图片(左)和我希望它看起来像(右).

我通过论坛阅读,在使用word文档时我还没有看到解决方案.我将不胜感激任何建议.
谢谢
chi*_*n12 16
您可以\newline在Rmd文件中使用如下:
---
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
Run Code Online (Sandbox Code Playgroud)
如果您要问下一个,新页面会稍微困难一些.您需要为标题5(例如)创建一个新的样式,在新页面上自动启动,在您的Rmd文件中,您将使用标题5作为新行.尽管如此,网上有相当多的资源.
Eri*_*ntz 14
2 年前我对答案投了赞成票,但现在 \newline 对我不起作用。但是, <br> 有效。确保 <br> 上方和下方有空白空间。也适用于图表和代码片段输出。
---
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!
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19454 次 |
| 最近记录: |