-
-
Notifications
You must be signed in to change notification settings - Fork 872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correctly check ghostscript for cropping on Windows #2246
Comments
If helpful, I'm happy to help test proposed changes. |
And here is where the existing cropping logic is included in the Quarto CLI: |
Oh thanks, they indeed do not use an exported or internal function from knitr ... too bad... 😞 |
I've implemented the logic in Thanks! |
Looks good !
@remlapmot can you test it to confirm ? |
Thanks indeed @yihui. This is now working well for me. Sorry that I have been slow to reply @cderv, I am a lecturer and I was teaching and then marking. I have checked this by uninstalling my external Ghostscript, and under the development version of knitr (1.42.10) on Windows, using TinyTeX (tlmgr 66798, TeX Live 2023). My test Rmd file was the following. ---
output: pdf_document
---
```{r include=FALSE}
if (!tinytex::check_installed('pdfcrop')) tinytex::tlmgr_install("pdfcrop")
knitr::knit_hooks$set(crop = knitr::hook_pdfcrop)
```
```{r, crop=TRUE}
plot(1:10)
```
```{r, crop=NULL}
plot(1:10)
``` Which produced the following pdf as expected (i.e., with the first figure cropped and the second figure uncropped). ![]() |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
Follows discussions in rstudio/tinytex#391
We need to make
knitr::plot_crop()
conditional on windows to use the ghotscript internal to TeX Live. The internal ghostscript is not found by our detection because it is not expose in path (which is on purpose by Tex Live)https://github.com/yihui/knitr/blame/1239f36c5dee8b0e029958a793ae71558902f52c/R/plot.R#L374
This is an adaptation of previous fix #954
But we may also need to reconsider in rmarkdown as we also check for ghostcript using
tools::find_gs_cmd()
https://github.com/rstudio/rmarkdown/blob/0e794e35717c3be9637e2b0468bb97010d84b527/R/util.R#L318-L331
My understand is that
However, the use of internal ghostcript is conditional to Tex Live version as from rstudio/tinytex#391 this is not working and an external program should be used.
Maybe using
grepl("TeX Live 2023", tinytex::tlmgr_version(FALSE))
?The text was updated successfully, but these errors were encountered: