【问题标题】:Can't insert plots in bookdown无法在 bookdown 中插入绘图
【发布时间】:2018-06-02 06:23:17
【问题描述】:

我正在使用 bookdown 为 R 生成注释。显示错误的最小 bookdown 示例:

https://github.com/DavisBrian/bookdown_error

在我尝试添加绘图 (dataviz.Rmd) 之前,一切都很好。在构建这本书时,我收到以下错误:

! LaTeX Error: File `dataviz_files/figure-latex/plotxyx-1' not found.

Error: Failed to compile rclassnotes.tex. See rclassnotes.log for more info.
In addition: Warning message:
In parse_packages(logfile, quiet = c(TRUE, FALSE, FALSE)) :
  Failed to find a package that contains dataviz_files/figure-latex/plotxyx-1
Execution halted

Exited with status 1.

我已经在下面运行了这个:

> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.4

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/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_3.4.4  backports_1.1.2 bookdown_0.7    magrittr_1.5    rprojroot_1.3-2 htmltools_0.3.6 tools_3.4.4    
 [8] yaml_2.1.18     Rcpp_0.12.16    stringi_1.1.7   rmarkdown_1.9   knitr_1.20      xfun_0.1        stringr_1.3.0  
[15] digest_0.6.15   evaluate_0.10.1

关于从这里去哪里有什么想法吗?

编辑:

它似乎非常类似于: https://github.com/rstudio/bookdown-demo/issues/3 和 https://github.com/rstudio/bookdown/issues/342

注意我在 Windows 和 Mac OSX 上都有这个问题。我认为这不是其中一个组件的简单软件安装错误。

这些文件似乎是在 _bookdown_files/dataviz_files/figure-latex/ 中创建的,并且暂时在 _dataviz_files/figure-latex/ 中创建

【问题讨论】:

  • 这些文件是创建的吗?
  • 是的,但它们似乎已被删除/清理。我可以在那里看到它们,直到发生错误。旁注,如果我使用 RStudio 编织按钮,一切正常。但是 Build Book 出错了
  • 有很多代码要看。您能否尝试构建一个演示该问题的最小示例?
  • @RalfStubner 将顶部的链接更新为一个最小的 bookdown 示例。

标签: r latex pandoc bookdown blogdown


【解决方案1】:

问题是由于您将图形设备设置为svg in _common.R: https://github.com/DavisBrian/bookdown_error/blob/9f4078a/_common.R#L13

knitr::opts_chunk$set(
  comment = "#>",
  collapse = TRUE,
  cache = FALSE,
  out.width = "70%",
  fig.align = 'center',
  fig.width = 6,
  fig.asp = 0.618,  # 1 / phi
  fig.show = "hold",
  dev = "svg"
)

LaTeX 本身不支持 SVG 图像(至少目前是这样)。您必须使用特殊的 LaTeX 包,或者使用 LaTeX 可以识别的图像格式,例如 pdf 或 png。

【讨论】:

猜你喜欢
  • 2016-11-07
  • 1970-01-01
  • 2017-09-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-28
  • 1970-01-01
  • 2013-11-15
相关资源
最近更新 更多