Rmarkdown到Word输出 - 在标题上方插入图像

问题描述 投票:3回答:1

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

我还没有找到解决方案。我尝试过使用pandoc_args--include-in-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>.
r r-markdown
1个回答
4
投票

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

然后,在YAML标题中:

---
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文件,输出应包含图像。

© www.soinside.com 2019 - 2024. All rights reserved.