英文:
Wrap horizontal code overflow in Quarto revealjs
问题
在Quarto中,是否有一种方法可以将长行代码包裹在revealjs输出中?code-overflow: wrap
,它在html
输出中有效,似乎在revealjs
中不起作用:
---
format: revealjs
---
## 一个标题
```{r}
#| echo: true
#| code-overflow: wrap
multipoint <- sf::st_multipoint(rbind(c(3.2,4), c(3,4.6), c(3.8,4.4), c(3.5,3.8), c(3.4,3.6), c(3.9,4.5)))
#这应该被包裹。
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/FKigp.png
<details>
<summary>英文:</summary>
Is there a way to have long lines of code wrapped in Quarto, revealjs output? `code-overflow: wrap`, which works for `html` output does not seem to work in `revealjs`:
---
format: revealjs
---
## A title
```{r}
#| echo: true
#| code-overflow: wrap
multipoint <- sf::st_multipoint(rbind(c(3.2,4), c(3,4.6), c(3.8,4.4), c(3.5,3.8), c(3.4,3.6), c(3.9,4.5)))
#This should be wrapped.
```
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/FKigp.png
</details>
# 答案1
**得分**: 2
你可以使用 [`width.cutoff`](https://stackoverflow.com/questions/26210656/in-r-markdown-in-rstudio-how-can-i-prevent-the-source-code-from-running-off-a-p) 属性(仅当通过 `knitr` 渲染时才可行):
```{r}
#| eval: false
#| echo: true
#| tidy: true
#| tidy.opts: { width.cutoff: 60 }
multipoint <- sf::st_multipoint(rbind(c(3.2,4), c(3,4.6), c(3.8,4.4), c(3.5,3.8), c(3.4,3.6), c(3.9,4.5)))
英文:
You can use the width.cutoff
property (only a viable option if you render via knitr
):
---
format: revealjs
---
## A title
Here is some example code
```{r}
#| eval: false
#| echo: true
#| tidy: true
#| tidy.opts: { width.cutoff: 60 }
multipoint <- sf::st_multipoint(rbind(c(3.2,4), c(3,4.6), c(3.8,4.4), c(3.5,3.8), c(3.4,3.6), c(3.9,4.5)))
```
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论