Vertical scrollbar for long functions with knitr slides

kable scroll box
rmarkdown table horizontal scroll
scroll_box kable
r markdown vertical scroll
kable scrollable
kable vertical lines
knitr::kable table width pdf
kable_styling

Is it possible to make vertical scrollbar for long functions with knitr slides (using xaringan custom style)? I was trying some options based on this previous question How to make vertical scrollbar appear in RMarkdown code chunks (html view) but no idea how to do it only for long functions (which height goes out of the frame). Any advice is more than welcome.

---
title: "title"
subtitle: "subtitle"
author: "author"
date: "2017"
output:
  xaringan::moon_reader:
    lib_dir: libs
    css: ["default", "style.css"]
    nature:
      highlightStyle: zenburn
      highlightLines: true
      countIncrementalSlides: false
---

```{r , echo=FALSE, include=FALSE}
library(knitr)
opts_chunk$set(fig.align='center', message=TRUE, error=TRUE, warning=TRUE, tidy=TRUE, comment = "##", echo = TRUE, dev='svg')
options(width=65)
```

```{r}
fu <- function(x){
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
}
```

I'm not an expert with CSS so can't guarantee that this is a robust solution, but adding max-height and overflow-y to the styling of code blocks seems to work well. Adjust the max-height as necessary, 200px is fairly short and only used to demonstrate how it works:

<style>
pre.sourceCode {
    max-height: 200px;
    overflow-y: auto;
}
</style>

I'm not sure if the class name for code blocks changes with different output formats, I was using slidy_presentation as I didn't have your renderer installed so you may have to check the class on your output.

scroll_box: Put a HTML table into a scrollable box in kableExtra , This function will put a HTML kable object in a fixed-height, fixed-width or both in LaTeX table · Create Awesome HTML Table with knitr::kable and kableExtra  The output of the above matrix extends to the bottom edge of the slide and then vanishes. No scrollbar. Vertical scrollbar for long functions with knitr slides

Have you tried the solution from this answer

.scrollable-slide {
    height: 800px;
    overflow-y: auto !important;
}

RaukR presentation demo, Note that the markdown interpreter used by remarkjs (blackfriday) is different from that used by knitr (pandoc). Normal text. .small[Small text] .smaller[Smaller text.] ":{"6a11665d7ab4":["function () ","plotlyVisDat"]},"cur_data":"6a11665d7ab4" slide in vertical direction, this can be limited to specific height along with scroll  I'm trying to activate the vertical scrolling option in my revealjs presentation for all the slides. I've tried adding the overflow option in the css directly within my .Rmd which makes the scroll bars appear on the presentation but my slide still overflows and I can't scroll down.

In your style.css, create a class that define y overflow as scroll and the desired height of the div (see this SO answer as a reference)

.pre {
  height: 10pc;
  overflow-y: scroll;
}

Then apply that css class to the code block:

.pre[
```{r}
fu <- function(x){
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
  x
}
```
]

10.3 Scrollable text output, title: Scrollable code blocks output: html_document: highlight: tango --- We set up an knitr::knit_hooks$get('output') knitr::knit_hooks$set(output = function(x,  Scroll bar overview. Below is an image of a Microsoft Windows window with a vertical and horizontal scroll bar. How to scroll and use the scroll bar. Scroll bars are utilized using the mouse, touchpad, or keyboard. With a mouse, you can move the scroll bar by clicking the scroll arrow at either end of the

Scrolling Area for Wide or Long Content · Issue #147 · yihui/xaringan , Scrolling Area for Wide or Long Content #147 The vertical and horizontal scrolling slide is then (from the sydney example presentation):  How to Make a Scrollbar in PowerPoint. Ordinary text boxes in Microsoft PowerPoint expand to accommodate their contents. If a single text box contains a large quantity of text, you can change its width or height, but you cannot shrink the box until it excludes some text -- PowerPoint will reshape the box to fit the

Scrollable code output · Issue #75 · yihui/rmarkdown-cookbook , It adds a scroll bar to R code chunk output so your html documents aren't made excessively long. title: "Untitled" output: html_document --- ```{r, include=FALSE​} knitr::knit_hooks$set(output = function(x, options){  The horizontal and vertical scroll bars in the Excel window are set by the size of the used range (the range of cells containing any value, formula, formatting etc). Occasionally, this range can become excessively large (normally by accident). As a result, the scroll bar becomes tiny.

R Markdown Basics (1) - IDRE Stats, Add a level 1 header called “Big Header” and a level 3 header called “Small Header” Note: Even though R Markdown calls knitr functions when rendering the is that the vertical size of slides is unlimited, as you can scroll down slides. How to fix scrollbar in excel to get rid of extra empty rows? In Excel 2003, sometimes Excel shows a large amount of blank rows and empty columns that was previously deleted, and somehow the scrollbar thinks there’s still data when there isn’t any.

Comments
  • It did not work. Maybe it has to be with the class on the output. The style I am using is example.css. How can I check the output class?