How to make vertical scrollbar appear in RMarkdown code chunks (html view)

前端 未结 2 780
太阳男子
太阳男子 2021-01-02 09:20

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

相关标签:
2条回答
  • 2021-01-02 09:51

    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;
    
    0 讨论(0)
  • 2021-01-02 09:58

    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)

    0 讨论(0)
提交回复
热议问题