Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Typst-figure-pasteToolsNew to Visual Studio Code? Get it now.
Typst-figure-pasteTools

Typst-figure-pasteTools

羽肿

|
5 installs
| (0) | Free
一款支持像word一样粘贴图片到Typst文档中的VSCode扩展
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Typst Figure Paste Tools

一款在 VS Code 中自动处理 Typst 文件图像粘贴操作的扩展。当在 .typst 文件中粘贴图像时,扩展会自动将图像保存到同一目录下并使用时间戳作为文件名,同时插入相应的 Typst 图像引用语法。

功能

  • 自动图像检测 :检测在 Typst 文件中粘贴图像的操作
  • 自动保存 :自动将图像保存到 Typst 文件所在目录,文件名基于时间戳
  • 代码插入 :在光标位置自动插入正确的 Typst 图像语法
  • 智能粘贴 :粘贴文本或非图像内容时,保持普通粘贴行为

要求

  • VS Code 版本 1.105.0 或更高
  • Windows(目前仅支持 Windows,macOS 与 Linux 支持即将推出)

使用方法

  1. 在 VS Code 中打开 .typst 文件
  2. 将图像复制到剪贴板
  3. 按 Ctrl+V 粘贴
  4. 扩展将会:
    • 检测到图像粘贴
    • 将图像保存到与 .typst 文件相同的目录
    • 在光标位置插入 Typst 代码(默认使用 #figure() 语法)

使用细节

当在 Typst 文件中粘贴图像时:

  • 图像会使用时间戳文件名保存(例如 1699123456789.png)
  • 图像保存在 Typst 文件所在目录
  • 插入代码(默认使用 #figure() 语法,可在设置中切换为 #image())

如果粘贴的是文本或其他内容:

  • 扩展会检测到不是图像,执行普通粘贴操作

配置

可以在 VS Code 设置中自定义图像插入方式,以下为可配置项:

设置项 默认值 说明
typst-figure-pastetools.useFigure true 使用 #figure() 而不是 #image() 语法
typst-figure-pastetools.includeCaption false 在 #figure() 语法中包含 caption 字段
typst-figure-pastetools.captionTemplate "" 默认的 caption 模板(留空则不包含 caption)
typst-figure-pastetools.imageWidth 100% 粘贴图像的默认宽度(如 100%、10cm、500pt)
typst-figure-pastetools.imageHeight 空 粘贴图像的默认高度,留空则自动(如 auto、10cm)
typst-figure-pastetools.imageFit contain 图像的适配方式:contain、cover、fit 或 none
typst-figure-pastetools.showImageSettings false 粘贴时是否弹出对话框配置图像设置
typst-figure-pastetools.enableImageDetection true 启用自动图像检测(禁用以避免任何延迟)

示例

使用 #figure() 语法(默认):

#figure(
  image("1699123456789.png", width: 80%),
  caption: "图片说明"
)

使用 #image() 语法(当 useFigure 为 false 时):

#image("1699123456789.png", width: 100%)

带 fit 选项:

#figure(
  image("1699123456789.png", width: 100%, fit: "cover"),
  caption: ""
)

已知问题

  • 目前仅支持 Windows,macOS 与 Linux 支持即将推出
  • 必须先保存文件后才能粘贴图像(未保存的文件会显示警告)
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft