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
相关产品推荐
相关产品推荐

