Skip to content

BUG with pdfcrop and fig_crop in v2.5 => plots not resized properly #1934

Closed

Description

@pkR-pkR

(Bug checked with cderv) The Rmd example below (except the \ before some triple backticks)(edited) describes a bug/regression introduced in v2.5 (and probably in v2.4) with pdfcrop and fig_crop. In Beamer presentation, the plots are not resized properly anymore in the slide. It is ugly. This is due to the fig_crop: true line in the yaml header. The same ugly slides appear if the line is missing. Currently, the only solution is to write fig_crop: false to get something clean, as in v2.3 and previous versions.

---
title: "A regression in rmarkdown from v_2.3 to v_2.5"
author: "pkR-pkR + cderv"
date: "October 23, 2020"
output: 
  beamer_presentation:
    template: default
    latex_engine: pdflatex
    keep_tex: true
    toc: false
    fig_caption: false
    fig_crop: true
fontsize: 10pt
--- 


# A regression in rmarkdown from v_2.3 to v_2.5

A regression in rmarkdown both on Windows and Debian:

- rmarkdown_2.3.tar.gz properly resizes the following plots
- rmarkdown_2.5.tar.gz badly resizes the following plots

The issue occurs/is linked to pdfcrop:

- Missing line **fig_crop**  in yaml header => BAD
- **fig_crop: true** in yaml header => BAD
- **fig_crop: false** in yaml header => OK

The current default settings break all previous .Rmd files.

Furthermore, pdfcrop on Windows is very slow.

Please, revert to the previous settings (pdfcrop disabled)!

(Bug reproduced by cderv)


# corrplot::corrplot() => OK with v_2.3, Bad with v_2.5

```{r echo=FALSE, message=FALSE, warning=FALSE}
corrplot::corrplot(matrix(runif(900), 30, 30))
```


# lattice::levelplot() => OK with v_2.3, Bad with v_2.5

```{r echo=FALSE, message=FALSE, warning=FALSE}
lattice::levelplot(matrix(runif(900), 30, 30))
```

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('rmarkdown'). 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('rstudio/rmarkdown').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

Activity

  1. added
    bug
    on Jan 6, 2022
  2. moved this from Backlog to Todo in R Markdown Team Projectson Jan 6, 2022
  3. added
    next
    and removed
    next
    on Jan 6, 2022
  4. added
    Won't Fix
    on Jan 12, 2022
  5. yihui commented on Jan 12, 2022

    @yihui
    Collaborator

    This was indeed a regression, but should only affect Windows users. In rmarkdown 2.3, fig_crop would be set to false on Windows no matter if the cropping tools are available, and would be set to false only if cropping tools are unavailable on other platforms. I don't remember why we made the exception for Windows now (probably because pdfcrop was buggy or hard to use on Windows), but I feel the exception doesn't make much sense and can cause inconsistent behaviors on different platforms. In v2.5, we removed the exception, and would do cropping as long as the tools are available.

    Unfortunately, we do not plan to bring back this exception to Windows users. It has been long since we made the previous change. If we revert the change, it may surprise other Windows users again. On the other hand, the fix for this issue appears to be simple enough (i.e., setting fig_crop: false). Therefore we tend not to make the change in rmarkdown.

    You described the slides as "ugly". I think it's essentially a matter of figure sizes. You can adjust plot sizes by using the chunk option out.width, e.g., shrinking the plots by out.width="70%".

    Apologies for the late response, and thanks for your understanding!

  6. Repository owner moved this from Todo to Done in R Markdown Team Projectson Jan 12, 2022
  7. github-actions commented on Jul 12, 2022

    @github-actions

    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.

  8. locked as resolved and limited conversation to collaborators on Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Won't Fixbug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions