简体   繁体   English

rstudio knitr 没有运行 pdfcrop

[英]rstudio knitr not running pdfcrop

I'm trying to knit the mwe below to pdf using rstudio (1.2.5019)我正在尝试使用 rstudio (1.2.5019) 将下面的 mwe 编织为 pdf

---
title: "Test"
author: "Me"
output: 
  pdf_document: 
    fig_caption: yes
    keep_tex: yes
    fig_crop: yes
---
This should be cropped
```{r}
library(knitr)
```



```{r named-chunk}
plot(x <- 0:100, dbinom(x, size=100, prob=0.6), type='l',
     main="Not cropped", xlab="Looks good", ylab="Nok")
```

The output pdf looks fine except the plot has not been cropped with pdfcrop.输出 pdf 看起来不错,只是该图尚未用 pdfcrop 裁剪。

Here's the log output.这是日志输出。

processing file: cropping.Rmd |..................处理文件:cropping.Rmd |................
| | 25% ordinary text without R code 25% 没有 R 代码的普通文本

|................................... |……………………
| | 50% label: unnamed-chunk-1 50% 标签:unnamed-chunk-1
|.................................................... |................................................................ ...
| | 75% ordinary text without R code 75% 没有 R 代码的普通文本

|......................................................................| |................................................................ …………| 100% label: named-chunk 100% 标签:命名块

output file: cropping.knit.md输出文件:cropping.knit.md

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS cropping.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output cropping.tex --self-contained --highlight-style tango --pdf-engine pdflatex --variable graphics --lua-filter "C:/Users/marti/Documents/R/win-library/3.6/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter "C:/Users/marti/Documents/R/win-library/3.6/rmarkdown/rmd/lua/latex-div.lua" --variable "geometry:margin=1in" "C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTScropping.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --outputcropping.tex --self-contained - -highlight-style tango --pdf-engine pdflatex --variable graphics --lua-filter "C:/Users/marti/Documents/R/win-library/3.6/rmarkdown/rmd/lua/pagebreak.lua" -- lua-filter "C:/Users/marti/Documents/R/win-library/3.6/rmarkdown/rmd/lua/latex-div.lua" --variable "geometry:margin=1in"

Output created: cropping.pdf创建的输出:cropping.pdf

pdfcrop works just fine from my command line but isn't called by rstudio. pdfcrop 在我的命令行中工作得很好,但没有被 rstudio 调用。 It is also located by rstudio.它也位于rstudio。

Sys.which('pdfcrop') pdfcrop "C:\\texlive\\2019\\bin\\win32\\pdfcrop.exe" Sys.which('pdfcrop') pdfcrop "C:\\texlive\\2019\\bin\\win32\\pdfcrop.exe"

What am I missing?我错过了什么?

This actually solved it.这实际上解决了它。

``` {r crop-hook,cache=FALSE}
    knit_hooks$set(crop=hook_pdfcrop)
```


```{r named-chunk, crop=TRUE}
plot(x <- 0:100, dbinom(x, size=100, prob=0.6), type='l',
     main="Not cropped", xlab="Looks good", ylab="Nok")
```

As far as I understood from the documentation this shouldn't be necessary?据我从文档中了解到,这应该没有必要吗?

通过livetexmiktex安装pdfcrop --- 您用来编写乳胶文档的那个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM