Rmarkdown 到 Word 输出 - 在标题上方插入图像 [英] Rmarkdown to Word output - insert image above header

查看:85
本文介绍了Rmarkdown 到 Word 输出 - 在标题上方插入图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Rmarkdown 文档,我正在将它输出到 Word,我正在尝试将公司徽标插入到页面顶部,在包含标题和作者的页眉上方.

I have an Rmarkdown document which I'm outputting to Word and I'm trying to insert a company logo to the top of the page, above the header that includes the title and author.

我还没有找到解决方案.我尝试使用 pandoc_args--include-in-header,但这没有成功.不过,我不确定我是否正确使用了它.

I haven't found a solution to this. I've tried using pandoc_args to --include-in-header, but this wasn't successful. I'm not confident that I was using it correctly though.

是否可以在标题上方包含图片?

Is it possible to include an image above the 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 模板中使用图像标题.在 Word 2010 中:插入标题 -> 图像并添加选择的图像.将此文档另存为 template_image.docx 与 .Rmd 文件位于同一文件夹中.

This is possible using image headers in a Word template. In Word 2010 go: insert header -> image and add the image of choice. Save this document as template_image.docx in the same folder as the .Rmd file.

然后,在 YAML 标头中:

Then, in the 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 文件,输出应包括图像.

Knit the .Rmd file and the output should include the image.

这篇关于Rmarkdown 到 Word 输出 - 在标题上方插入图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆