-1

R shows this: Warning: Error in : pandoc document conversion failed with error 1 [No stack trace available]

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

1 Answers1

0

It should be fig_caption: true, not fig_caption: yes.

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

The aruments that word_document accepts can be seen by checking ?rmarkdown::word_document. This help page says that fig_caption is logical.

EDIT(based on your comment): It seems that the flie "headingfive.docx" does not exist or you're in the wrong directory.

If you dont have the file yet you can check out these two links to see how its created:

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

Finally youll have to make sure that the file "headingfive.docx" is in R's working directory(at least that's where it needs to be on Ubuntu).

Grada Gukovic
  • 1,228
  • 7
  • 13
  • Thank you so much, but it still did not work. And I checked my rmarkdown and pandox versions are newest, why it shows "pandoc.exe: headingfive.docx: openBinaryFile: does not exist (No such file or directory) Warning: Error in : pandoc document conversion failed with error 1"? [No stack trace available] – Suzanne.Yang Jul 19 '19 at 12:23
  • It seems that the flie "headingfive.docx" does not exist or you're in the wrong directory. When I gave as a "reference_docx" a file that doesnt exist I got the same error message. – Grada Gukovic Jul 20 '19 at 17:59
  • Had similar issues, had to put my reference docx file in both the parent directory and sub directory in which rmarkdown file was. Not the most elgant, but the error got resolved. – radhikesh93 Aug 20 '20 at 14:29