TMwR icon indicating copy to clipboard operation
TMwR copied to clipboard

wrapping errors and warnings to page width

Open topepo opened this issue 6 years ago • 3 comments

A modification of yihui/knitr#1142 that works for bookdown (knit_hooks is not exposed when rendering in bookdown)

topepo avatar Jan 13 '20 15:01 topepo

@cderv This and issue #5 are examples of (what appears to be) knitr options not working in bookdown.

topepo avatar Sep 01 '20 01:09 topepo

Thanks ! I'll have a look !

cderv avatar Sep 01 '20 07:09 cderv

It is possible that your hook is correct but where is loaded does not work. Here is a full analysis https://github.com/rstudio/bookdown/issues/1252#issuecomment-913530117

Basically when new_session: yes, before_chapter_script is sourced before render(), as each file is rendered in a different session. This means that it is possible that some options (like knitr configuration) does not apply because overwrittren by render(). Usually in a document project, those change of behavior for knitr are done in a setup chunk. And with a bookdown project this would apply. Some different way to load a common file in all document are shared in the issue linked above.

That may be what causes the hook you defined to not work.

No issue I think if you use new_session: false

BTW there is also this solution but that would apply to all outputs https://bookdown.org/yihui/rmarkdown-cookbook/text-width.html

cderv avatar Feb 04 '22 15:02 cderv