I\'ve found many examples outlining how to add horizontal scrollbars to R Markdown HTML output, including this specific example here. However, none that describe how to add
Adding onto @Martin Schmelzer's solution, I noticed there can be issues if echo = TRUE
, or if your output is not much large in other parts of the document. To fix this issue just change:
height: 50vh !important;
to
max-height: 50vh !important;
The problem seems to be that you did not specify the height of the code chunk. Try this instead:
<style>
pre {
white-space: pre !important;
overflow-y: scroll !important;
height: 50vh !important;
}
</style>
(For information about the unit vh
check this)