When I output my rmarkdown document as a pdf, really long comments don’t wrap. For example:
x = 1 + 1 #This is a comment that will be written super duper long to see if it wraps around the document or if it trails off.
When I knit the document into pdf, the result is the comment trails off the page and does not wrap around.
I researched this problem and tried two things:
- Downloading the formatR package and then using “tidy=TRUE, tidy.opts=list(width.cutoff=60)” as an option in the {r} bracket. I made sure to use library(formatR) in a code chunk at the top of my document like so:
library(formatR)
I also tried using library(formatR) in the code chunk with the long comment as well as the “tidy=TRUE, tidy.opts=list(width.cutoff=60)” option in that code chunk.
- Using the below global statement:
knitr::opts_chunk$set(tidy.opts = list(width.cutoff = 60), tidy = TRUE)
The first solution did not wrap the comment like I wanted it to. The second solution wrapped long code but not the comment for the code. How can I get long comments to wrap, too?