简体   繁体   中英

How to properly set rendering Rmarkdown to pdf?

I use Rmarkdown to generate reports and if my line is too long it is usually cut after rendering.

Is there a way to fix it?

I attach a screenshot in order better explain my issue.

在此处输入图片说明

You can use the chunk option tidy=TRUE to automatically insert line breaks in the code.

---
output: pdf_document
---

```{r, tidy = TRUE}
c(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0)
```

The linebreaks are inserted by formatR::tidy_source() . See https://yihui.org/knitr/options/#code-decoration for more details.

chunk_content <- "c(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0)"
formatR::tidy_source(text = chunk_content, width.cutoff = 30)
#> c(1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
#>     1, 2, 3, 4, 5, 6, 7, 8, 9,
#>     0, 1, 2, 3, 4, 5, 6, 7, 8,
#>     9, 0, 1, 2, 3, 4, 5, 6, 7,
#>     8, 9, 0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM