@davidgohel
当我使用officedown::rpptx_document
编织 Rmd 文件时,该函数会生成一个无法打开的 pptx 文件,并带有以下错误消息:
PowerPoint found a problem with content in xxxx.pptx.
PowerPoint can attempt to repair the presentation.
我确认 Rmd 的内容是可编织的,例如bookdown::powerpoint_presentation2
。 因此,我怀疑officedown::rpptx_document
中可能存在一些错误。
---
title: "Untitled"
author: "CLRR"
date: "2020/6/20"
output:
officedown::rpptx_document:
keep_md: TRUE
bookdown::powerpoint_presentation2:
keep_md: TRUE
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## R Markdown
This is an R Markdown presentation. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.
## Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
## Slide with R Output
```{r cars, echo = TRUE}
summary(cars)
```
## Slide with Plot
```{r pressure}
plot(pressure)
```
rmarkdown::pandoc_version()
[1] ‘2.9.2.1’
R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale:
[1] LC_COLLATE=Japanese_Japan.932 LC_CTYPE=Japanese_Japan.932 LC_MONETARY=Japanese_Japan.932 LC_NUMERIC=C LC_TIME=Japanese_Japan. 932
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
Rcpp_1.0.4.6
packrat_0.5.0
digest_0.6.25
R6_2.4.1
magrittr_1.5
officedown_0.1.0
evaluate_0.14
zip_2.0.4
gdtools_0.2.2
rlang_0.4.6
uuid_0.1-4
xml2_1.3.2
rmarkdown_2.2
tools_4.0.0
officer_0.3.11
xfun_0.14
yaml_2.2.1
compiler_4.0.0
systemfonts_0.2.3 r
vg_0.2.4
memoise_1.1.0
htmltools_0.4.0
knitr_1.28
感谢您报告。
似乎它只发生在 R for Windows 上。 我还不知道问题出在哪里。
首先:
感谢您提供的很棒的包裹 - 真的很棒! 很高兴使用/使用它——尤其是与 flextable 相关的。
从我的角度来看,windows上的问题可能是由reference_doc的值引起的。
虽然在officer中使用pptx模板似乎在windows上不起作用(见下文),但代码使用pandoc参考模板工作:
---
title: "Untitled"
author: "CLRR"
date: "2020/6/20"
output:
officedown::rpptx_document:
# not working:
# reference_doc: C:/R/lib/officer/template/template.pptx
# set reference_doc to standard pandoc layout:
# system2(rmarkdown::pandoc_exec(), args = c("--print-default-data-file", "reference.pptx"), stdout = "C:/R/pandoc_layout.pptx")
reference_doc: C:/R/pandoc_layout.pptx
keep_md: TRUE
---
## R Markdown
Test
模板的选择 - 使用官员内部模板而不是 pandocs 参考文档 - 可能会在函数 officedown:::get_default_pandoc_data_file 中触发
请参阅启用 Pandoc-pptx-reference doc 的使用。
@mtkerbeR
您建议的 R 控制台上的以下命令不起作用:
> system2(rmarkdown::pandoc_exec(), args = c("--print-default-data-file", "reference.pptx"), stdout = "C:/R/pandoc_layout.pptx")
pandoc.exe: <stdout>: hPutBuf: invalid argument (Bad file descriptor)
pandoc_layout.pptx 应该先在哪里退出? 还是我应该自己创建一个 pptx 文件? 我的R
C
目录,即没有C:/R/
。 我有C:\Program Files\R
, C:\Program Files\RStudio
, C:\Users\my-user-name\AppData\Local\RStudio
, C:\Users\my-user-name\AppData\Local\RStudio
。
@davidgohel和@mtkerbeR
现在我成功得到了一个pptx文件!
(1)我在某个目录(此时C:/Users/my-user-name/Documents/R
)创建了pandoc_layout.pptx ,并且
(2) 按照@mtkerbeR的建议运行以下代码:
system2(rmarkdown::pandoc_exec(), args = c("--print-default-data-file", "reference.pptx"), stdout = "C:/Users/my-user-name/Documents/R/pandoc_layout.pptx")
(3) 然后我在 YAML 中使用选项reference_doc: C:/Users/my-user-name/Documents/R/pandoc_layout.pptx
编织了一个 Rmd 文件。
谢谢
这现在在 github 版本中得到修复。
有两个问题,一个是窗口缺少.exe
,另一个是关于用作reference_doc
的临时文件。 感谢@mtkerbeR的帮助
我确认 github 版本的officedown::rpptx_document
会生成一个可打开的文件。 这太棒了! 感谢@davidgohel的错误修复和@mtkerbeR的有益贡献!