5 css knitr r-markdown remarkjs xaringan
是否可以使用 knitr 幻灯片(使用xaringan自定义样式)为长功能制作垂直滚动条?我正在尝试基于上一个问题如何使垂直滚动条出现在 RMarkdown 代码块(html 视图)中的一些选项,但不知道如何仅对长函数(高度超出框架)执行此操作。任何建议都非常受欢迎。
---
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
}
```
Run Code Online (Sandbox Code Playgroud)
我不是 CSS 专家,所以不能保证这是一个强大的解决方案,但在代码块的样式中添加 max-height 和 Overflow-y 似乎效果很好。根据需要调整 max-height,200px 相当短,仅用于演示其工作原理:
<style>
pre.sourceCode {
max-height: 200px;
overflow-y: auto;
}
</style>
Run Code Online (Sandbox Code Playgroud)
我不确定代码块的类名是否会随着不同的输出格式而变化,我使用的slidy_presentation是因为我没有安装渲染器,所以您可能必须检查输出上的类。
| 归档时间: |
|
| 查看次数: |
1066 次 |
| 最近记录: |