When trying to knit my Rmarkdown files to PDF, knitr
doesn't seem to wrap the comments and the text just goes outside of the pdf margins.
I have tried specifying several parameters but nothing seems to have any effect.
---
title: "Demo margin"
output: pdf_document
---
```{r setup, include=FALSE}
options(width=80)
knitr::opts_chunk$set(echo = TRUE,out.width = 40, tidy=T, tidy.opts=list(width.cutoff=60))
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars, out.width=80, tidy = 'formatR', tidy.opts = list(blank = FALSE, width.cutoff = 60)}
summary(cars)
#very very very very very very very very very very very very very very very very very very very very very very very very incredibly very long comment
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)
Matrix products: default
locale:
[1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.6.1 htmltools_0.4.0 tools_3.6.1 yaml_2.2.0 Rcpp_1.0.3
[6] rmarkdown_2.0 knitr_1.26 xfun_0.11 digest_0.6.23 rlang_0.4.2
[11] evaluate_0.14
How can I get knitr
to wrap the comments within the margins?