summaryrefslogtreecommitdiff
path: root/tests/typ
diff options
context:
space:
mode:
authorMALO <57839069+MDLC01@users.noreply.github.com>2023-09-12 14:47:36 +0200
committerGitHub <noreply@github.com>2023-09-12 14:47:36 +0200
commit976abdfe7dc08ae42ee87e5c2d4ff46ebe172dd1 (patch)
tree836d1b46f9e2e25205eb0f85c1c65a216bc9d655 /tests/typ
parente39be71a54a4264032115ab3b31bdd86845a966b (diff)
Add `figure.caption` element (#1704)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'tests/typ')
-rw-r--r--tests/typ/meta/figure-caption.typ56
-rw-r--r--tests/typ/meta/figure.typ2
-rw-r--r--tests/typ/meta/query-figure.typ2
3 files changed, 58 insertions, 2 deletions
diff --git a/tests/typ/meta/figure-caption.typ b/tests/typ/meta/figure-caption.typ
new file mode 100644
index 00000000..2a12cc22
--- /dev/null
+++ b/tests/typ/meta/figure-caption.typ
@@ -0,0 +1,56 @@
+// Test figure captions.
+
+---
+// Test figure.caption element
+#show figure.caption: emph
+
+#figure(
+ [Not italicized],
+ caption: [Italicized],
+)
+
+---
+// 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],
+)
+
+---
+// 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
+ #it.counter.display(it.numbering))
+]
+
+#figure(
+ [Another figure],
+ kind: "custom",
+ caption: [Hi],
+ supplement: [B],
+)
diff --git a/tests/typ/meta/figure.typ b/tests/typ/meta/figure.typ
index 48dea0e8..62d163a9 100644
--- a/tests/typ/meta/figure.typ
+++ b/tests/typ/meta/figure.typ
@@ -41,7 +41,7 @@ We can clearly see that @fig-cylinder and
#show figure.where(kind: "theorem"): it => {
let name = none
if not it.caption == none {
- name = [ #emph(it.caption)]
+ name = [ #emph(it.caption.body)]
} else {
name = []
}
diff --git a/tests/typ/meta/query-figure.typ b/tests/typ/meta/query-figure.typ
index b1e59abe..0540d65a 100644
--- a/tests/typ/meta/query-figure.typ
+++ b/tests/typ/meta/query-figure.typ
@@ -17,7 +17,7 @@
Figure
#numbering(it.numbering,
..counter(figure).at(it.location())):
- #it.caption
+ #it.caption.body
#box(width: 1fr, repeat[.])
#counter(page).at(it.location()).first() \
]