1

最近,我在编织自己的word文件时尝试将word模板文件导入papaja,以便我可以根据自己的规范自定义样式。我偶然发现了这篇文章(在使用 rmd 模板时为文字输出格式化文本),所以我尝试使用此功能,但我一直遇到错误。

代码如下:

output: 
  papaja::apa6_word:
    reference_docx: "reference.docx"

如果我排除了导入参考 word 文档的代码(所以只是output: papaja::apa6_word),RMD 编译并吐出一个 word 文档,没有任何问题。因此,问题似乎完全是由于尝试导入 word 文档所致。

我在下面包含了我的错误信息、一些背景信息和会话信息。

背景资料:

  1. 我正在使用这个 papaja 版本:devtools::install_github("crsh/papaja@devel")正如之前的帖子中所建议的那样。
  2. 我尝试导入的 docx 文件与 RMD 文件在同一个文件中,因此文件不在正确的工作目录中不是问题;这是输出dir(getwd())
[1] "reference.docx"             "manuscript.docx"                "manuscript.rmd"                  "plos-one.csl"                   
  1. 文件本身不是问题;我尝试创建一个没有任何内容的空白word文档并用它替换“reference.docx”。没有骰子。仅更改文档文件中的一种样式也不起作用。

错误:

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

会话信息:

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

谢谢大家; 任何信息都会有所帮助,因为我一直在努力让这件事发挥作用。

4

0 回答 0