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

如何为Typst的figure图片添加边框?

给Typst的Figure添加细黑色边框

因为figure本身没有内置的border参数,你可以通过以下两种方法实现需求:

  • 方法一:用box包裹图像内容
    在figure内部,把图像(或其他内容)放进box组件中,给box设置边框属性即可:

    figure(
      caption: "带细黑边框的示例图",
      box(
        border: (width: 0.5pt, color: black),
        image("example.png", width: 100%),
      ),
    )
    

    其中width: 0.5pt控制边框粗细,color: black定义边框颜色,可根据需求调整数值。

  • 方法二:全局统一设置figure边框
    若要给所有figure自动添加边框,可通过set figure结合decorator实现全局配置:

    set figure(decorator: box.with(border: (width: 0.5pt, color: black)))
    
    figure(
      caption: "全局统一边框的图",
      image("example.png", width: 100%),
    )
    

    该设置会作用于后续所有figure,无需逐个单独配置。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.23 01:59:55