Poor resolution and blurry texts when using knitr to create a PDF file in Rmarkdown?

Viewed 566

EDIT: Never mind! It seems like the PREVIEW generated by RSTUDIO is blurry. The actual PDF looks fine!

I'm using knitr package to create a PDF report in rmarkdown. I'm using kableExtra package to embed a table. However, the resolution of the said table is poor and the contents are blurry.

Did anyone else have this problem? I looked at increasing the DPI, but it seems like that's only for plots and not tables.

This is my example Rmarkdown file:

---
output: 
  pdf_document: 
     latex_engine: xelatex
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
\```

```{r, echo=FALSE}
library(kableExtra)

mtcars[1:6] %>%
  kable("latex", booktabs = TRUE, linesep = "") %>%
  kable_styling(
    full_width=TRUE, 
    bootstrap_options = c("striped"),
  )
\```
1 Answers

Besides Rmarkdown, I certainly had problems with blurry PDF's in R knitr/kable. My solution was easy (but hard to find though). During saving procedure with save_kable, include the desired resolution with the command density. For example: save_kable("yourdata.pdf", density = 300). See also here: Why does save_kable to PDF result in bad quality PDFs?

Related