使用 classoption:landscape 时无法从 R markdown 生成横向的 microsoft word 文档

AP3*_*P30 4 landscape orientation r-markdown

使用 RStudio 和 Rmarkdown 时,我无法生成横向文档。

R 是 3.4.2 版 RStudio 是 0.98.1103 版

我无法更改这些,因为它们是我运行程序的集群上的最新版本。

编织文件后,我确实得到了一个文件(以纵向形式),但是收到以下错误消息:

Output created: test_landscape.docx
Warning message:
In (function (toc = FALSE, toc_depth = 3, fig_width = 5, fig_height = 4,  :
  table of contents for word_document requires pandoc >= 1.14
Run Code Online (Sandbox Code Playgroud)

可重现的代码在这里:

---
title: "test_landscape"
author: "Name"
date: "09/10/2018"
output: word_document
classoption: landscape
---

Test for landscape orientation

```{r}
summary(cars)
```

You can also embed plots, for example:

```{r, echo=FALSE}
plot(cars)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
Run Code Online (Sandbox Code Playgroud)

不确定这是否更适合交叉验证,因为 R 是一种统计编程语言,但问题不是统计语言。

谢谢你。

编辑:在下面的评论后编辑标题以更好地代表我的问题。

AP3*_*P30 5

感谢拉尔夫·斯图纳。

对于如何在此处专门针对 word 执行此操作的过程有一个很好的解释:https : //rmarkdown.rstudio.com/articles_docx.html

您必须创建一个具有所需设置(例如横向)的 Word 文档,将其保存在与 .Rmd 文件相同的位置,然后将其作为参考文档引用,例如:

---
title: "test_landscape"
author: "Name"
date: "09/10/2018"
output: 
  word_document:
    reference_docx: word_styles.docx
---
Run Code Online (Sandbox Code Playgroud)

  • 这是一个功能强大的解决方案,有很多优点,但也因为 Word 而存在很多可能的、不可预测的坏处。我会指出,标头似乎需要 YAML 正确解释换行符和缩进,至少在我探索此选项时是这样。 (2认同)