Skip to content
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

[knitr] Update pdf cropping detection to latest knitr version and allow opt out using crop: false chunk option #7877

Merged
merged 4 commits into from Dec 11, 2023

Conversation

cderv
Copy link
Collaborator

@cderv cderv commented Dec 11, 2023

This PR

It update our R code to use the latest fix from yihui/knitr#2246 (when recent version of knitr is used)

and it adds support to use crop: false chunk option to opt out cropping feature in PDF.

Either at chunk level

```{r}
#| crop: false
library(ggplot2)
ggplot() + theme(plot.margin = margin(t=2,b=2,unit='cm')) # wide margins to see the effect (or lack thereof)
```

or globally

knitr:
  opts_chunk: 
    crop: false

The usual knitr way is crop: null but this is less known and easy to remember

knitr:
  opts_chunk: 
    crop: null

and

```{r}
#| crop: null
library(ggplot2)
ggplot() + theme(plot.margin = margin(t=2,b=2,unit='cm')) # wide margins to see the effect (or lack thereof)
```

@cderv cderv merged commit 1b208f6 into main Dec 11, 2023
@cderv cderv deleted the knitr/pdf-crop branch December 11, 2023 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant