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

在RStudio中用Quarto+LaTeX生成PDF,如何设置部分内容双栏?

在Quarto PDF文档中实现局部双栏布局

你遇到的问题是:Quarto的.columns容器在HTML渲染时能正常生成双栏,但PDF(PDFLaTeX后端)渲染时失效,以下是两种可行的解决方法:

方法1:使用Quarto原生的layout-ncol属性

Quarto提供了跨格式的布局属性,layout-ncol=2可以直接在PDF中生成双栏,写法简洁:

---
format: pdf
---

Some heading text.

::: {layout-ncol=2}
text in col1

text in col2
:::

Some bottom text.

方法2:嵌入LaTeX原生代码(适合复杂布局)

如果需要更精细的布局控制,可以直接使用LaTeX的multicol环境,Quarto会自动处理LaTeX代码的渲染:

---
format: pdf
---

Some heading text.

\begin{multicols}{2}
text in col1

text in col2
\end{multicols}

Some bottom text.

说明

原来的.columns类是Quarto为HTML等Web格式设计的CSS布局类,LaTeX后端无法识别该类,因此需要使用上述针对PDF的专用布局方式。在Mac系统的RStudio中点击「render」按钮,两种方法都能通过PDFLaTeX渲染出预期的局部双栏PDF文档。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.08 11:00:06