jhelvy / renderthis

An R package for building xaringan slides into multiple outputs, including html, pdf, png, gif, pptx, and mp4.
https://jhelvy.github.io/renderthis
Other
172 stars 12 forks source link

Missing plots due to messed up margins in PDF but not HTML #69

Closed bshor closed 1 year ago

bshor commented 1 year ago

I am still having problems with plots extending past the margins and then not being included in PDF output.

@gadenbuie suggested including a red outline to see the problem. Well, this red outline shows fine on the HTML, but totally past the margins in the PDF (produced using to_pdf in renderthis).

HTML:

image

PDF:

image

Any idea about what I shoudl do?

jhelvy commented 1 year ago

Same as #44

bshor commented 1 year ago

Right but look at how much the plot shifted. It's not an issue of margins, as the margins are rather tight around the plot itself, and there's even some separation between the red line and the edge of the slide.

In any case, perhaps some kind of simple shrink would do the trick. Do you have suggestions to shrink plots like this, both from PNGs and code-generated plots?

bshor commented 1 year ago

Wait ... I figured it out. The plot was fine, but not the figure caption, which extended below the slide. So setting out.width to be smaller did the trick, as did eliminating the caption. Thanks for the help and pointers!