While I am knitting a document as a PDF using RMarkdown some code chunk outputs exceeds the page margins as seen on the pic.
Any ideas to fix this?

Many functions do not respond correctly to the page size config. So to solve such an issue, you have to include the following configuration for the output file.
output: 
  pdf_document:
    pandoc_args: --listings
    includes:
      in_header: preamble.tex
create the file preamble.tex in the same folder where the Rmarkdown file exists, and its content is the following:
\lstset{
  breaklines=true
}
For more information, check https://bookdown.org/yihui/rmarkdown-cookbook/text-width.html.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With