You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Quarto代码块是否支持输出折叠?如何实现?

在Quarto中折叠代码块的输出内容

当然有!Quarto提供了output-fold选项专门用来控制代码块输出内容的折叠,用法和你熟悉的code-fold类似,直接在代码块的YAML选项里设置即可。

比如你提到的R语言sessionInfo()输出,只需要给代码块加上#| output-fold: true就能默认隐藏输出,读者点击就能展开查看:

#| output-fold: true

sessionInfo()

如果需要自定义折叠区域的提示文字,可以搭配output-fold-summary选项,比如:

#| output-fold: true
#| output-fold-summary: "点击展开会话信息"

sessionInfo()

要是想同时折叠代码和对应的输出,就把code-fold和output-fold两个选项一起用:

#| code-fold: true
#| output-fold: true

sessionInfo()

内容的提问来源于stack exchange,提问作者Joe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 05:22:02