【问题标题】:Why my r-markdown docx output "reference_docx: headingfive.docx" did not work?为什么我的 r-markdown docx 输出“reference_docx:headingfive.docx”不起作用?
【发布时间】:2019-11-27 22:12:38
【问题描述】:

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

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

【问题讨论】:

    标签: r output r-markdown


    【解决方案1】:

    应该是 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/

    How to add a page break in word document generated by RStudio & markdown

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

    【讨论】:

    • 非常感谢,但还是不行。我检查了我的 rmarkdown 和 pandox 版本是最新的,为什么它显示“pandoc.exe:headingfive.docx:openBinaryFile:不存在(没有这样的文件或目录)警告:错误:pandoc 文档转换失败,错误 1”? [没有可用的堆栈跟踪]
    • 苍蝇“headingfive.docx”似乎不存在,或者您在错误的目录中。当我将一个不存在的文件作为“reference_docx”提供时,我收到了相同的错误消息。
    • 有类似的问题,不得不将我的参考 docx 文件放在 rmarkdown 文件所在的父目录和子目录中。不是最优雅的,但错误得到了解决。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-06-03
    • 1970-01-01
    • 2019-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多