Rmarkdown 到 Word 输出 - 在上方插入图片 header

Rmarkdown to Word output - insert image above header

我有一个要输出到 Word 的 Rmarkdown 文档,我试图在页面顶部插入一个公司徽标,位于包含标题和作者的 header 上方。

我还没有找到解决办法。我试过使用 pandoc_args--include-in-header,但这并不成功。我不确定我是否正确使用了它。

是否可以在 header 上方添加图片?

---
title: "Untitled"

author: "r.bot"
date: "Thursday, January 1, 2015"
output:
  word_document:
    fig_caption: yes
    fig_height: 5
    fig_width: 5
    reference_docx: template.docx
    pandoc_args:  [
      "--include-in-header", "C:\path\to\file.png"
    ]
---

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

这可以在 Word 模板中使用图像 headers。在 Word 2010 中:插入 header -> 图像并添加选择的图像。在与 .Rmd 文件相同的文件夹中将此文档另存为 template_image.docx

然后,在 YAML header:

---
title: "Untitled"
author: "Simon"
date: "Thursday, May 21, 2015"
output:
  word_document:
    fig_caption: yes
    fig_height: 5
    fig_width: 5
    reference_docx: template_image.docx
---

编织 .Rmd 文件,输出应包含图像。