m-d*_*-dz 9 html css r knitr r-markdown
在html文件中设置r代码输出宽度的当前工作解决方案是什么?我想将宽度设置为大的并在html输出中使用滑块.
options(width = XXX) 似乎不再工作了.
---
title: "Width test"
output:
html_document:
theme: default
---
```{r global_options, echo = FALSE, include = FALSE}
options(width = 999)
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE,
cache = FALSE, tidy = FALSE, size = "small")
```
```{r}
sessionInfo()
```
```{r}
dataM <- matrix(rnorm(100, 5, 2), ncol = 15)
dataM
```
Run Code Online (Sandbox Code Playgroud)
sessionInfo()输出在上面的截图中.
(options(width = 999)不适合我)
raw*_*awr 15
如果pre块溢出,您可以使用它来使块水平滚动.
---
title: "Width test"
output:
html_document:
theme: default
---
<style>
pre {
overflow-x: auto;
}
pre code {
word-wrap: normal;
white-space: pre;
}
</style>
```{r global_options, echo = FALSE, include = FALSE}
options(width = 999)
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE,
cache = FALSE, tidy = FALSE, size = "small")
```
```{r}
sessionInfo()
```
```{r}
dataM <- matrix(rnorm(100, 5, 2), ncol = 20)
dataM
```
Run Code Online (Sandbox Code Playgroud)
对于可滚动高度,创建一个具有最大高度和一个overflow-y: auto;或的容器divoverflow-y: scroll;
---
title: "Height test"
output:
html_document:
theme: default
---
<style>
.pre-scrolly {
max-height: 150px;
overflow-y: auto;
}
</style>
<div class='pre-scrolly'>
```{r}
sessionInfo()
```
</div>
Run Code Online (Sandbox Code Playgroud)
您可以重置width并max-width使用自定义 CSS,例如:
---
title: "Width test"
output:
html_document:
theme: default
---
<style>
.main-container { width: 1200px; max-width:2800px;}
</style>
```{r global_options, echo = FALSE, include = FALSE}
options(width = 999)
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE,
cache = FALSE, tidy = FALSE, size = "small")
```{r}
sessionInfo()
```
```{r}
dataM <- matrix(rnorm(100, 5, 2), ncol = 15)
dataM
```
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3968 次 |
| 最近记录: |