【问题标题】:R markdown word ducument output marginsR markdown word文档输出边距
【发布时间】:2017-08-17 03:46:43
【问题描述】:

我有一个关于设置rmarkdownword_document 输出ma​​rgins 的问题。
我浏览了很多信息,找到了reference
可以使用geometry进行设置。但是,我只希望单词输出边距变得非常小。我还找到this 来设置边距。
但是,它没有用。

---
title: "Set Margins"
output: word_document
geometry: margins: left = 0.1 cm
                   right = 0.1 cm 
---

如何判断?

【问题讨论】:

  • 我相信geometry 是一个 LATEX 包,只有在你将它编织成 PDF 时才能工作。只需使用 Microsoft Word 中的视图标尺以您想要的方式自定义边距
  • 并非所有 pandoc 的选项都可以通过rmarkdown 获得(您提供的第二个参考是 Latex 包,当然又不一样了!)。但是你可以使用a style reference as explained here

标签: r output r-markdown margins


【解决方案1】:

对于您之前使用 R 降价生成的 word 文档,将其命名为 margin_styles.docx,并调整该文档中的边距以适应所需的输出。然后在 rmarkdown (.Rmd) 文件的 yaml 部分包含以下内容:

---
output:
  word_document:
    reference_docx: margin_styles.docx
---

渲染文件的边距应该设置在margin_styles.docx

有关更多详细信息,请参阅 rmarkdown 文档的样式参考部分http://rmarkdown.rstudio.com/word_document_format.html#style_reference

【讨论】: