I've been using officedown to create reports for a while, and recently started to implement flextables to create tables with proper layouts. However, the structure of my report means there is one master .Rmd, which imports subsections from a subfolder. Whenever attempting to add a flextable to one of these subsections, it attempts to search for the master markdown's reference_docx within the subsections folder, even though any reference to that should be run while working in the main folder. When writing other code and text and referring to variables, everything is executed in the context of the main Rmd.
The exact error:
Quitting from lines NA-7 (./subsections/subsection.Rmd) Error: could not find file 'word_templates/template.docx' Execution halted
In terms of the reproducible example:
reprex.Rmd uses reference_docx, found at word_templates/template.docx
subsection.Rmd is imported in reprex.Rmd, and all of its code is executed in the context of reprex.Rmd in the base folder. However, once it has a flextable, it attempts to look for reference_docx in subsections/word_templates/template.docx.
Reproducible example
This can be reproduced with the following file structure:
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.3 htmltools_0.5.0 tools_4.0.3 yaml_2.2.1 tinytex_0.27 rmarkdown_2.5 knitr_1.30
[8] digest_0.6.27 xfun_0.19 rlang_0.4.9 evaluate_0.14
Note: I'm not entirely sure whether this belongs in the issues of `flextable`, `officer`, or `officedown`. If you want me to repost it in another repository, please let me know.
Issue
I've been using officedown to create reports for a while, and recently started to implement flextables to create tables with proper layouts. However, the structure of my report means there is one master .Rmd, which imports subsections from a subfolder. Whenever attempting to add a flextable to one of these subsections, it attempts to search for the master markdown's
reference_docx
within thesubsections
folder, even though any reference to that should be run while working in the main folder. When writing other code and text and referring to variables, everything is executed in the context of the main Rmd.The exact error:
In terms of the reproducible example: reprex.Rmd uses reference_docx, found at
word_templates/template.docx
subsection.Rmd is imported in reprex.Rmd, and all of its code is executed in the context of reprex.Rmd in the base folder. However, once it has a flextable, it attempts to look for reference_docx insubsections/word_templates/template.docx
.Reproducible example
This can be reproduced with the following file structure:
reprex.rmd in the main folder
output: word_document
Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages: [1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached): [1] compiler_4.0.3 htmltools_0.5.0 tools_4.0.3 yaml_2.2.1 tinytex_0.27 rmarkdown_2.5 knitr_1.30
[8] digest_0.6.27 xfun_0.19 rlang_0.4.9 evaluate_0.14