【问题标题】:Rmarkdown can't find a .png image while trying to compile on pdf using papaja尝试使用 papaja 在 pdf 上编译时,Rmarkdown 找不到 .png 图像
【发布时间】:2020-02-06 04:34:17
【问题描述】:

我正在尝试在 r-markdown 中使用papaja 格式制作文档。问题是 R 无法编译 pdf,因为它找不到我尝试使用 `knitr::include_graphics() 导入的图像。

这是我的 Yaml 标头:

---
title             : "Something"
author: 
  - name          : "my name"
bibliography      : ["Draft.bib"]
floatsintext      : yes
figsintext        : yes
figurelist        : no
tablelist         : no
footnotelist      : no
linenumbers       : yes
link-citations    : yes
mask              : no
draft             : no
documentclass     : "apa6"
classoption       : "man"
output            : 
  pdf_document : papaja::apa6_pdf
header-includes:
  - \usepackage{setspace}
  - \AtBeginEnvironment{tabular}{\singlespacing}
  - \AtBeginEnvironment{lltable}{\single  espacing}
  - \AtBeginEnvironment{tablenotes}{\doublespacing}
  - \captionsetup[table]{font={stretch=1.5}}
  - \captionsetup[figure]{font={stretch=1.5}}
---

This is the chunk where I am trying to import the image:

```{r colors}
knitr::include_graphics("figures/colors.png")
```

请注意,我已经检查了我的 wd,并且我的图像路径中没有任何空格

最后这是 R 在尝试编译时打印的错误:

!!! Error: Input file `Draft_files/figure-latex/colors-1.pdf' not found!

Quitting from lines 87-88 (Draft.Rmd) 
Error in magick_image_readpath(enc2native(path), density, depth, strip) : 
  R: unable to open image `Draft_files/figure-latex/colors-1.png': No such file or directory @ error/blob.c/OpenBlob/2874
Calls: <Anonymous> ... in_dir -> plot_crop -> <Anonymous> -> magick_image_readpath
Execution halted

我也尝试将路径更改为./figures/colors.png,但结果是一样的。

任何帮助将不胜感激!

【问题讨论】:

    标签: pdf r-markdown png knitr papaja


    【解决方案1】:

    这是 knitr 开发版中的a known bughas been fixed。请尝试开发版本

    remotes::install_github('yihui/knitr')
    

    或等待下一个版本的 knitr (v1.28) 出现在 CRAN 上(希望在几天后)。

    或者,您可以在块上设置块选项crop=NULL,例如

    ```{r colors, crop=NULL}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-26
      • 1970-01-01
      • 2021-12-27
      • 2021-04-22
      • 2016-08-19
      • 2021-03-24
      • 2019-08-29
      相关资源
      最近更新 更多