Reputation: 515
When I compile my Bookdown books for pdf output I get figures cut by the left and right margins. This does not happen if I generate them with ggsave()
myself and then add them with knitter::include_graphics()
.
---
output:
pdf_document: default
html_document: default
---
# Example
```{r example, message=FALSE}
require(tidyverse)
ggplot(data=iris, aes(x=Sepal.Length, y=Sepal.Width))+geom_point()
```
I execute `bookdown::render("index.Rmd", output_format=pdf_book(keep_tex=TRUE))
I get this image as output (in main_files/figure-latex)
Is this a bug or is it just me? How can I solve it? I do not like very much the idea of ggsave()
+ knitr::include_image()
, but it is the only workaround I got so far.
> xfun::session_info('bookdown')
R version 3.6.2 (2019-12-12)
Platform: x86_64-suse-linux-gnu (64-bit)
Running under: openSUSE Leap 15.1, RStudio 1.2.5019
Locale:
LC_CTYPE=es_ES.UTF-8 LC_NUMERIC=C LC_TIME=es_ES.UTF-8
LC_COLLATE=es_ES.UTF-8 LC_MONETARY=es_ES.UTF-8 LC_MESSAGES=es_ES.UTF-8
LC_PAPER=es_ES.UTF-8 LC_NAME=C LC_ADDRESS=C
LC_TELEPHONE=C LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION=C
Package version:
base64enc_0.1.3 bookdown_0.17 digest_0.6.18 evaluate_0.14 glue_1.3.1
graphics_3.6.2 grDevices_3.6.2 highr_0.3 htmltools_0.4.0 jsonlite_1.6
knitr_1.28 magrittr_1.5 markdown_1.1 methods_3.6.2 mime_0.8
Rcpp_1.0.3 rlang_0.4.4 rmarkdown_2.1 stats_3.6.2 stringi_1.2.4
stringr_1.4.0 tinytex_0.18 tools_3.6.2 utils_3.6.2 xfun_0.8
yaml_2.2.0
Upvotes: 1
Views: 179
Reputation: 30114
If you take a look at the fig_crop
argument on the help page ?rmarkdown::pdf_document
, you will see that figure files will be cropped by default if pdfcrop
is available. You can turn this feature off via:
output:
pdf_document:
fig_crop: false
Upvotes: 2