forked from nju-lug/modern-nju-thesis
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbilingual-figure.typ
58 lines (52 loc) · 1.5 KB
/
bilingual-figure.typ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#import "../utils/style.typ": 字号, 字体
// 中英双语图片标题函数(支持手动编号)
#let bilingual-figure(
body,
caption: none,
caption-en: none,
kind: "figure",
supplement: auto,
numbering: "1.1", // 使用章节-序号格式
gap: 0.65em, // 图片与标题间距
caption-position: bottom, // 标题位置
manual-number: none, // 手动指定编号
) = context {
let sup = if supplement == auto {
if kind == "figure" { "图" }
else if kind == "table" { "表" }
else { kind }
} else { supplement }
let sup-en = if supplement == auto {
if kind == "figure" { "Figure" }
else if kind == "table" { "Table" }
else { kind }
} else { supplement }
// 创建显示编号的函数
let display-number = if manual-number != none {
manual-number
} else {
counter(kind).display(numbering)
}
set figure.caption(position: caption-position)
figure(
body,
caption: if caption != none{
[
#set text(font: 字体.宋体, size: 字号.小四, weight: "regular")
#set align(center)
#sup #display-number #caption
#if caption-en != none {
[
#set text(font: 字体.宋体, size: 字号.五号, weight: "regular")
#set align(center)
#sup-en #display-number #caption-en
]
}
]
},
kind: kind,
gap: gap,
supplement: "", // 设置为空字符串,因为我们已在caption中手动处理
numbering: none,
)
}