【发布时间】:2020-07-09 16:24:06
【问题描述】:
我正在尝试运行一些代码,希望它能让我在编织到 docx 时使用 kableExtra:
library(kableExtra)
kable(mtcars, "latex", booktabs = T) %>%
kable_styling(latex_options = c("striped", "scale_down")) %>%
row_spec(1, color = "red") %>%
as_image()
(此处借用代码:https://haozhu233.github.io/kableExtra/save_kable_and_as_image.html)
在运行上面的代码之前,我安装了 ghostscript 和这些包(按照说明):
install.packages("magick")
install.packages("webshot")
webshot::install_phantomjs()
当我按下 knit 时,我会收到以下消息:
This is XeTeX, Version 3.14159265-2.6-0.999992 (TeX Live 2020/W32TeX) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
Error in save_kable_latex(x, file, latex_header_includes, keep_tex) : We hit an error when trying to
use magick to read the generated PDF file. You may check your magick installation and try to use
magick::image_read to read the PDF file manually. It's also possible that you didn't have ghostscript
installed.
所以,我尝试使用 magick::image_read 手动读取 PDF 文件,这只会导致“R Session Aborted”(magick 中的类似功能:magick::image_read_pdf 工作得很好)。
我该如何解决这个问题?
【问题讨论】:
标签: r-markdown docx kableextra