From f347ed4314e32383dc09ff234180e8ea6fef7b8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20d=27Herbais=20de=20Thun?= Date: Tue, 4 Apr 2023 19:21:25 +0200 Subject: Improved figure numbering, labelling and referencing (#491) --- tests/ref/meta/figure.png | Bin 26011 -> 103112 bytes tests/typ/meta/counter.typ | 10 +++--- tests/typ/meta/figure.typ | 80 +++++++++++++++++++++++++++++++++++++++++++++ tests/typ/meta/query.typ | 2 ++ 4 files changed, 87 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/ref/meta/figure.png b/tests/ref/meta/figure.png index c1b518d3..a86b4d6d 100644 Binary files a/tests/ref/meta/figure.png and b/tests/ref/meta/figure.png differ diff --git a/tests/typ/meta/counter.typ b/tests/typ/meta/counter.typ index 32d16cae..6b5797de 100644 --- a/tests/typ/meta/counter.typ +++ b/tests/typ/meta/counter.typ @@ -45,8 +45,8 @@ At Beta, it was #locate(loc => { --- // Count figures. -#figure(numbering: "A", caption: [Four 'A's])[_AAAA!_] -#figure(numbering: none, caption: [Four 'B's])[_BBBB!_] -#figure(caption: [Four 'C's])[_CCCC!_] -#counter(figure).update(n => n + 3) -#figure(caption: [Four 'D's])[_DDDD!_] +#figure(numbering: "A", caption: [Four 'A's], kind: image, supplement: "Figure")[_AAAA!_] +#figure(numbering: none, caption: [Four 'B's], kind: image, supplement: "Figure")[_BBBB!_] +#figure(caption: [Four 'C's], kind: image, supplement: "Figure")[_CCCC!_] +#counter(figure.where(kind: image)).update(n => n + 3) +#figure(caption: [Four 'D's], kind: image, supplement: "Figure")[_DDDD!_] diff --git a/tests/typ/meta/figure.typ b/tests/typ/meta/figure.typ index 567e0431..3537bbe1 100644 --- a/tests/typ/meta/figure.typ +++ b/tests/typ/meta/figure.typ @@ -22,3 +22,83 @@ We can clearly see that @fig-cylinder and table(columns: 3)[a][b][c][d][e][f], caption: [The complex table.], ) + +--- + +// Testing figures with and without caption +#figure( + table( + columns: 2, + [First cylinder], + image("/cylinder.svg", height: 3cm), + ) +) + +#figure( + table( + columns: 2, + [Second cylinder], + image("/cylinder.svg", height: 3cm), + ), + caption: "A table containing images." +) + +--- + +// Testing show rules with figures with a simple theorem display +#show figure.where(kind: "theorem"): it => { + let name = none + if not it.caption == none { + name = [ #emph(it.caption)] + } 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)] + ) + ) +} + +#figure( + $a^2 + b^2 = c^2$, + supplement: "Theorem", + kind: "theorem", + caption: "Pythagoras' theorem.", + numbering: "1", +) + +#figure( + $a^2 + b^2 = c^2$, + supplement: "Theorem", + kind: "theorem", + caption: "Another Pythagoras' theorem.", + numbering: none, +) + +#figure( + caption: [Hello world in #emph[rust].], +)[ + #show raw: set align(left) + ```rust + fn main() { + println!("Hello, world!"); + } + ``` +] \ No newline at end of file diff --git a/tests/typ/meta/query.typ b/tests/typ/meta/query.typ index 8f8dcd3d..7dfbbcfc 100644 --- a/tests/typ/meta/query.typ +++ b/tests/typ/meta/query.typ @@ -61,6 +61,8 @@ #figure( rect[Just some stand-in text], + kind: image, + supplement: "Figure", caption: [Stand-in text], ) -- cgit v1.2.3