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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
// Test figures.
--- figure-basic ---
#set page(width: 150pt)
#set figure(numbering: "I")
We can clearly see that @fig-cylinder and
@tab-complex are relevant in this context.
#figure(
table(columns: 2)[a][b],
caption: [The basic table.],
) <tab-basic>
#figure(
pad(y: -6pt, image("/assets/images/cylinder.svg", height: 2cm)),
caption: [The basic shapes.],
numbering: "I",
) <fig-cylinder>
#figure(
table(columns: 3)[a][b][c][d][e][f],
caption: [The complex table.],
) <tab-complex>
--- figure-align ---
#show figure: set align(start)
#figure(
rect[This is \ left],
caption: [Start-aligned]
)
--- figure-table ---
// Testing figures with tables.
#figure(
table(
columns: 2,
[Second cylinder],
image("/assets/images/cylinder.svg"),
),
caption: "A table containing images."
) <fig-image-in-table>
--- figure-theorem ---
// Testing show rules with figures with a simple theorem display
#show figure.where(kind: "theorem"): it => {
set align(start)
let name = none
if not it.caption == none {
name = [ #emph(it.caption.body)]
} else {
name = []
}
let title = none
if not it.numbering == none {
title = it.supplement
if not it.numbering == none {
title += " " + it.counter.display(it.numbering)
}
}
title = strong(title)
pad(
top: 0em, bottom: 0em,
block(
fill: green.lighten(90%),
stroke: 1pt + green,
inset: 10pt,
width: 100%,
radius: 5pt,
breakable: false,
[#title#name#h(0.1em):#h(0.2em)#it.body#v(0.5em)]
)
)
}
#set page(width: 150pt)
#figure(
$a^2 + b^2 = c^2$,
supplement: "Theorem",
kind: "theorem",
caption: "Pythagoras' theorem.",
numbering: "1",
) <fig-formula>
#figure(
$a^2 + b^2 = c^2$,
supplement: "Theorem",
kind: "theorem",
caption: "Another Pythagoras' theorem.",
numbering: none,
) <fig-formula>
#figure(
```rust
fn main() {
println!("Hello!");
}
```,
caption: [Hello world in _rust_],
)
--- figure-breakable ---
// Test breakable figures
#set page(height: 6em)
#show figure: set block(breakable: true)
#figure(table[a][b][c][d][e], caption: [A table])
--- figure-caption-separator ---
// Test custom separator for figure caption
#set figure.caption(separator: [ --- ])
#figure(
table(columns: 2)[a][b],
caption: [The table with custom separator.],
)
--- figure-caption-show ---
// Test figure.caption element
#show figure.caption: emph
#figure(
[Not italicized],
caption: [Italicized],
)
--- figure-caption-where-selector ---
// Test figure.caption element for specific figure kinds
#show figure.caption.where(kind: table): underline
#figure(
[Not a table],
caption: [Not underlined],
)
#figure(
table[A table],
caption: [Underlined],
)
--- figure-and-caption-show ---
// Test creating custom figure and custom caption
#let gap = 0.7em
#show figure.where(kind: "custom"): it => rect(inset: gap, {
align(center, it.body)
v(gap, weak: true)
line(length: 100%)
v(gap, weak: true)
align(center, it.caption)
})
#figure(
[A figure],
kind: "custom",
caption: [Hi],
supplement: [A],
)
#show figure.caption: it => emph[
#it.body
(#it.supplement
#context it.counter.display(it.numbering))
]
#figure(
[Another figure],
kind: "custom",
caption: [Hi],
supplement: [B],
)
--- figure-caption-position ---
#set figure.caption(position: top)
--- figure-caption-position-bad ---
// Error: 31-38 expected `top` or `bottom`, found horizon
#set figure.caption(position: horizon)
--- figure-localization-fr ---
// Test French
#set text(lang: "fr")
#figure(
circle(),
caption: [Un cercle.],
)
--- figure-localization-zh ---
// Test Chinese
#set text(lang: "zh")
#figure(
rect(),
caption: [一个矩形],
)
--- figure-localization-ru ---
// Test Russian
#set text(lang: "ru")
#figure(
polygon.regular(size: 1cm, vertices: 8),
caption: [Пятиугольник],
)
--- figure-localization-gr ---
// Test Greek
#set text(lang: "gr")
#figure(
circle(),
caption: [Ένας κύκλος.],
)
--- issue-2165-figure-caption-panic ---
#figure.caption[]
--- issue-2328-figure-entry-panic ---
// Error: 4-43 footnote entry must have a location
// Hint: 4-43 try using a query or a show rule to customize the footnote instead
HI#footnote.entry(clearance: 2.5em)[There]
--- issue-2530-figure-caption-panic ---
#figure(caption: [test])[].caption
--- issue-3586-figure-caption-separator ---
// Test that figure caption separator is synthesized correctly.
#show figure.caption: c => test(c.separator, [#": "])
#figure(table[], caption: [This is a test caption])
|