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

Quarto在RStudio中多图重复标题及子图标签位置调整求助

解决Quarto .qmd中重复图标题与子图标签位置问题

方案1:仅保留单个主标题,去除重复标题

把两个绘图代码放在同一个R代码块中,通过块参数指定总标题并取消子图的自动标题:

#| fig-cap: "Figure 1: This is the label of picture."
#| layout-ncol: 2  # 可选,让两图并排,按需调整
#| fig-subcap: ~   # 取消子图的默认标题输出

# 基础绘图示例
plot(mtcars$mpg, mtcars$disp)

# ggplot绘图示例
library(ggplot2)
ggplot(mtcars, aes(mpg, hp)) + geom_point()

核心逻辑:将多个绘图合并到同一代码块后,Quarto会将其视为一个图组,仅显示fig-cap指定的总标题,不会为每个子图单独生成带编号的标题。

方案2:保留单个主标题+子图标签移至左上角

同样将绘图放在同一代码块,通过fig-subcap-location参数强制子图标签((a)/(b))显示在左上角,同时保留总标题:

#| fig-cap: "Figure 1: This is the label of picture."
#| layout-ncol: 2
#| fig-subcap: ["(a)", "(b)"]  # 可添加子图描述,如["(a) 散点图1", "(b) 散点图2"]
#| fig-subcap-location: top-left

# 基础绘图
plot(mtcars$mpg, mtcars$disp)

# ggplot绘图
library(ggplot2)
ggplot(mtcars, aes(mpg, hp)) + geom_point()

全局设置(可选)

如果所有图组都需要子图标签左上角显示,可在文档YAML头部统一配置:

format:
  pdf:  # 或 html/docx,适配你的输出格式
    fig-subcap-location: top-left

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.03 13:07:20