编译为 PDF 时 bookdown 中可能存在错误。图像被边缘切割
Possible bug in bookdown when compiling to PDF. Images get cut by the margins
当我为 pdf 输出编译我的 Bookdown 书籍时,我得到的数字被左右边距切割。如果我自己用 ggsave()
生成它们,然后用 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()
```
我执行`bookdown::render("index.Rmd", output_format=pdf_book(keep_tex=TRUE))
我将此图像作为输出(在 main_files/figure-latex 中)
这是一个错误还是只有我?我该如何解决?我不太喜欢 ggsave()
+ knitr::include_image()
的想法,但这是我目前唯一的解决方法。
关于我的系统的额外信息
> 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
如果您查看帮助页面 ?rmarkdown::pdf_document
上的 fig_crop
参数,您会发现如果 pdfcrop
可用,图形文件将默认被裁剪。您可以通过以下方式关闭此功能:
output:
pdf_document:
fig_crop: false
当我为 pdf 输出编译我的 Bookdown 书籍时,我得到的数字被左右边距切割。如果我自己用 ggsave()
生成它们,然后用 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()
```
我执行`bookdown::render("index.Rmd", output_format=pdf_book(keep_tex=TRUE))
我将此图像作为输出(在 main_files/figure-latex 中)
这是一个错误还是只有我?我该如何解决?我不太喜欢 ggsave()
+ knitr::include_image()
的想法,但这是我目前唯一的解决方法。
关于我的系统的额外信息
> 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
如果您查看帮助页面 ?rmarkdown::pdf_document
上的 fig_crop
参数,您会发现如果 pdfcrop
可用,图形文件将默认被裁剪。您可以通过以下方式关闭此功能:
output:
pdf_document:
fig_crop: false