首页 > 解决方案 > 为什么我的 r-markdown docx 输出“reference_docx:headingfive.docx”不起作用?

问题描述

R 显示:警告:错误:pandoc 文档转换失败,错误 1 ​​[没有可用的堆栈跟踪]

output: 
  word_document:
    fig_caption: yes
    toc: true
    toc_depth: 2
    reference_docx: headingfive.docx

标签: routputr-markdown

解决方案


它应该是 fig_caption: true,而不是 fig_caption: yes。

---
output: 
  word_document:
    fig_caption: true
    toc: true
    toc_depth: 2
    reference_docx: headingfive.docx
---  

word_document通过检查可以看到接受的参数?rmarkdown::word_document。该帮助页面说这fig_caption是合乎逻辑的。

编辑(根据您的评论):苍蝇“headingfive.docx”似乎不存在,或者您在错误的目录中。

如果您还没有该文件,您可以查看这两个链接以了解其创建方式:

https://www.r-bloggers.com/r-markdown-how-to-insert-page-breaks-in-a-ms-word-document/

如何在 RStudio 和 markdown 生成的 word 文档中添加分页符

最后,您必须确保文件“headingfive.docx”位于 R 的工作目录中(至少在 Ubuntu 上它需要位于该目录中)。


推荐阅读