yihui / bookdown-crc

A minimal example of using bookdown to write a book for Chapman & Hall/CRC
https://yihui.name/en/2018/08/bookdown-crc/
MIT License
72 stars 66 forks source link

Soft wrap long code output in pdf_output #5

Closed ColinFay closed 3 years ago

ColinFay commented 3 years ago

Hey,

First of all, thanks for this template, it saved us a lot of time :)

I'm facing a little issue I can't figure out (and thanks @cderv from trying to solve it with me 💪):

When printing the book to pdf, some of the code outputs overflow the width of the pdf.

This happens with the default template from here, and can be reproduced as such:

cd /tmp 
git clone https://github.com/yihui/bookdown-crc
cd bookdown-crc/
R -e 'bookdown::render_book("index.Rmd", "bookdown::pdf_book");browseURL(.Last.value)'

Here is the output of page 9:

Screenshot 2020-11-19 at 09 39 02

What I've tried:

None of these seemed to solve the issue completely: changing the font size works to a certain extent, but for very long line the code still overflow.

Are there any solution to correct this?

Thanks for your help, Colin

yihui commented 3 years ago

This actually has been a mystery to me, because I don't know why the lines were automagically wrapped in my books and I didn't use listings or knitr hooks, e.g.,

image

I'll take a closer look, but can't spend too much time on it for now, so I can't promise I'll figure it out. You can proceed with writing your book, and I'm sure this problem is fixable.

yihui commented 3 years ago

Should be fixed with ad8521c, but I still don't understand why the lines could be automatically wrapped...