library(knitr)
hook_output <- knit_hooks$get('output')
knit_hooks$set(output = function(x, options) {
# this hook is used only when the linewidth option is not NULL
if (!is.null(n <- options$linewidth)) {
x = xfun::split_lines(x)
# any lines wider than n should be wrapped
if (any(nchar(x) > n)) x = strwrap(x, width = n)
x = paste(x, collapse = '\n')
}
hook_output(x, options)
}
)
to solve wrapping text output in a Quarto PDF output, however, it produces an error:
Error in hook_output(x, options) : could not find function "hook_output"
Calls: .main ... <Anonymous> -> lapply -> FUN -> <Anonymous> -> <Anonymous>
Execution halted
Attempting to use https://github.com/yihui/knitr-examples/blob/master/077-wrap-output.Rmd
to solve wrapping text output in a Quarto PDF output, however, it produces an error: