What is the current working solution to set the width of r code output in html files? I would like to set width to something big and use a slider in the html output.
options(width = XXX)
seems not to work anymore.
---
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
```
sessionInfo() output on the screenshot above.
(options(width = 999)
is not working for me)
knitr: How to prevent text wrapping in output?
How to adjust the output width of RStudio Markdown output (to HTML)
To change the output size you can use the corresponding LaTeX commands, set just before the code junk. The smallest option would be \tiny . For a full overview consider e.g. this. After the code junk it's important to set back to the size you used before, e.g. \normalsize .
To transform your markdown file into an HTML, PDF, or Word document, click the “Knit” icon that appears above your file in the scripts editor. A drop down menu will let you select the type of output that you want. When you click the button, rmarkdown will duplicate your text in the new file format.
By default, RMarkdown rendered as HTML are self-contained. This means you can compile the document into HTML file and simply email it to a colleague. It should have all that is needed to render the document on your colleague's web browser.
When using knitr, how do you denote the height an width of a plot created in a code chunk ? Answer : Set the 'fig. height' and 'fig. width' options for the code chunk.
You can use this to make the pre
blocks scroll horizontally if it overflows.
---
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
```
For a scrollable height, create a container div with a max height and a overflow-y: auto;
or overflow-y: scroll;
Similar question/answer
---
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With