Recently, I was trying to import a word template file into papaja when knitting my own word files so that I can customize styles according to my specifications. I stumbled across this post (Format text for word output while using rmd template) so I tried using this functionality, but I keep running into an error.
The code is as below:
output:
papaja::apa6_word:
reference_docx: "reference.docx"
If I exclude the code to import the reference word document (so simply just output: papaja::apa6_word
), the RMD compiles and spits out a word document without any issues. So it definitely seems like the issue is solely due to trying to import the word document.
I included information of my error, some background information, and session info below.
Background Info:
- I'm using this papaja version:
devtools::install_github("crsh/papaja@devel")
as suggested in the earlier post. - The docx file I'm trying to import is in the same file as the RMD file, so it isn't an issue with the file not being in the correct working directory; here is the output from
dir(getwd())
[1] "reference.docx" "manuscript.docx" "manuscript.rmd" "plos-one.csl"
- The document itself isn't an issue; I tried creating a blank word document with nothing on it and replacing "reference.docx" with it. No dice. Changing only one style in the document file doesn't work either.
Error:
Error in file(con, "r") : cannot open the connection
Calls: <Anonymous> -> <Anonymous> -> readLines -> file
In addition: Warning message:
In file(con, "r") :
cannot open file 'word/header2.xml': No such file or directory
Execution halted
Session Info:
R version 4.0.4 (2021-02-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] papaja_0.1.0.9997 rstudioapi_0.13 knitr_1.33 magrittr_2.0.1 usethis_2.0.1 devtools_2.4.0 pkgload_1.2.1 R6_2.5.0 rlang_0.4.11
[10] fastmap_1.1.0 tools_4.0.4 pkgbuild_1.2.0 xfun_0.22 sessioninfo_1.1.1 tinytex_0.31 cli_2.5.0 withr_2.4.2 htmltools_0.5.1.1
[19] ellipsis_0.3.2 remotes_2.3.0 yaml_2.2.1 digest_0.6.27 rprojroot_2.0.2 lifecycle_1.0.0 crayon_1.4.1 processx_3.5.1 purrr_0.3.4
[28] callr_3.7.0 vctrs_0.3.8 fs_1.5.0 ps_1.6.0 testthat_3.0.2 curl_4.3.1 evaluate_0.14 memoise_2.0.0 glue_1.4.2
[37] cachem_1.0.4 rmarkdown_2.7 compiler_4.0.4 tinylabels_0.2.1 desc_1.3.0 prettyunits_1.1.1
Thank you all in advance; any information would be helpful as I've been pulling my hair out just trying to get this thing to work.