Skip to content

Commit

Permalink
Update dual_language_caption.md
Browse files Browse the repository at this point in the history
  • Loading branch information
flaribbit authored Feb 1, 2025
1 parent 816ce05 commit 8e95409
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions docs/FAQ/dual_language_caption.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,24 @@ tags: [figure, show]

# figure 的 caption 如何实现双语?

我个人推荐封装一个myfig(body, zhcaption, encaption)

然后调用figure(body, kind: 'myfig', caption: metadata((.......zhcaption......encaption)))

然后show figure.where(kind: 'myfig')从metadata里把双语拿出来
可以把双语用 `metadata` 存到 `caption` 里面,然后在 `show figure` 里面把双语拿出来

```typst
等人来写()
#let bifig(body, capzh, capen) = figure(
body,
supplement: none,
kind: "bifig",
caption: metadata((capzh, capen)),
)
#show figure.where(kind: "bifig"): it => {
let (capzh, capen) = it.caption.body.value
let c = it.counter.display("1")
it.body
parbreak()
[图 #c: #capzh]
parbreak()
[Figure #c: #capen]
}
#bifig(rect(), "启动", "start")
```

0 comments on commit 8e95409

Please sign in to comment.