将空白行添加到Word输出RMarkdown

编程入门 行业动态 更新时间:2024-10-28 14:34:30
本文介绍了将空白行添加到Word输出RMarkdown的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

美好的一天.

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

I am trying to create a conference abstract submission using a rmarkdown file which exports to a word document. I am trying to find a way to insert a blank line in the outputted word document. I have found that a line break can be inserted by adding two blank spaces at the end of a markdown file, however, this trick does not work when you simply want a blank line. Below is example code

--- 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

当我编织文档时,可惜的是它有点簇.在下面,我添加了一张带有当前输出的图片(左)和我想要的样子(右).

When I knit the document, sadly its a little clustered. Below I've added a picture with the current output (left) and what I would like it to look like (right).

我已经阅读了所有论坛,但在使用Word文档时,还没有看到解决方案.我将不胜感激.

I have read through forums and I have yet to see a solution for this when using a word document. I would appreciate any suggestions.

谢谢

推荐答案

您可以在Rmd文件中使用\newline,如下所示:

you can use \newline in the Rmd file as follows:

--- 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

如果您要问下一个问题,则新页面会稍微难一些.您将需要在标题5中创建一个新样式(例如),该样式会自动在新页面上启动,在Rmd文件中,您将标题5用作新行.网上有很多与此相关的资源.

In case you are going to ask next, newpage is slightly harder. You will need to create a new style in word for Heading 5 (for e.g.) which auto starts on a new page and in your Rmd file you will use heading 5 as your new line. there are quite a number of resources online regarding this though.

更多推荐

将空白行添加到Word输出RMarkdown

本文发布于:2023-06-03 08:56:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/470179.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:空白   Word   RMarkdown

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!