-
-
Notifications
You must be signed in to change notification settings - Fork 878
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
Don't overwrite input files specified in knitr::include_graphics()
#1800
Comments
As you seem to have discovered, this issue is not relevant to As you have also discovered in #1796, the fix is to disable cropping. You are right that this behavior should be more clearly documented on the help page |
Completely "inadvertently", yes. I don't use BiocStyle, but of course rmarkdown to render my R Markdown documents to PDF.
I don't consider this to be a proper fix. I strongly think it should be possible to use knitr's built-in PDF cropping without touching the original input files specified in
That's only half the battle, I think. Before today, I didn't even know about |
I was not the person who brought this feature to rmarkdown originally. If I were to write the |
I meant no offence! I absolutely appreciate all the amazing work you put into the R ecosystem!
I don't know much about the internals, but wouldn't it be possible (and if so, the best solution) to rework this cropping feature in such a way that the original input files specified in |
That sounds reasonable. Please give me a little more time to think about it. Thanks for the excellent suggestion! (BTW, I didn't feel offended at all 😄) |
Just a small addendum: I'm almost sure that before knitr 1.27, |
You are correct! |
Images included via |
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. |
I also ran into #1797 after updating to knitr 1.27. Then I updated to the dev version (1.27.2) and stumpled upon another issue I'd call a bug, too:
It seems that knitr is always overwriting the file included through
knitr::include_graphics()
. I don't know if this was already the case before knitr 1.27. I noticed it because I tried to build an MVE for the original bug using knitr's reference card PDF vignette as follows:Since I've installed knitr through Michael Rutter's PPA (Ubuntu Linux), on my system the above is equivalent to:
When I try to build this, the following error is thrown:
This is of course because knitr isn't run as root, but the file is owned by root and knitr doesn't have write permission:
I verified this with a file knitr actually has write permission to – it gets overwritten when included through
knitr::include_graphics()
! The documentation ofknitr::include_graphics()
doesn't say anything about possible file modifications of parampath
and I believe it was never really intended to overwritepath
, right?Addendum: I've just read about the
crop
option in #1796 and settingknitr::opts_chunk$set(crop = NULL)
avoids knitr's attempt to overwrite the included PDF.I think it's fine that knitr automatically crops white space around the files specified in
knitr::include_graphics()
but it should still never overwrite the original files!And is there a specific reason why@yihui 's answer:crop
isn't a "proper" chunk options like e.g.fig.path
?By filing an issue to this repo, I promise that
xfun::session_info('knitr')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('yihui/knitr')
.I understand that my issue may be closed if I don't fulfill my promises.
The text was updated successfully, but these errors were encountered: