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

Quarto Reveal.js幻灯片左图右文布局失败:columns与layout-ncol无效求助

解决Quarto Reveal.js幻灯片左图右文布局问题

问题原因

  • 使用layout-ncol=2时,容器内的每个顶级元素会被分配到一列,你原本的代码里有三个顶级元素(两段独立文本+图片),导致布局不符合预期。
  • 第二个.columns示例的列顺序搞反了,你需要左图右文,但代码里先放置了文本列,再放图片列。

解决方案

方法1:使用.columns自定义宽度(推荐)

调整列的顺序和宽度,确保所有文本在同一列内,直接实现左图右文:

---
format: revealjs
---

## 左图右文布局示例

:::: .columns
::: {.column width=40%}
![](https://www.r-project.org/logo/Rlogo.png)
:::
::: {.column width=60%}
Some text that is very long and that should take most of the column space.

Some other text that should be below the first paragraph.
:::
::::

方法2:使用layout-ncol=2配合嵌套容器

如果想用layout-ncol,需要把所有文本放在一个嵌套容器里,确保容器内只有两个顶级元素(图片+文本容器):

---
format: revealjs
---

## 左图右文布局示例

::: {layout-ncol=2}
![](https://www.r-project.org/logo/Rlogo.png)
:::
Some text that is very long and that should take most of the column space.

Some other text that should be below the first paragraph.
:::
:::

关键说明

  • .columns与.column组合可精确控制每列宽度,适合需要自定义布局的场景。
  • layout-ncol是自动分栏逻辑,仅适合内容数量与列数匹配的简单场景,如需分组内容,必须用嵌套容器包裹。

内容的提问来源于stack exchange,提问作者Maël

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 20:05:23