diff options
| author | Sébastien d'Herbais de Thun <sebastien.d.herbais@gmail.com> | 2023-04-04 19:21:25 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-04 19:21:25 +0200 |
| commit | f347ed4314e32383dc09ff234180e8ea6fef7b8b (patch) | |
| tree | dba4296812a131e52da4eb0079fd0d240860d832 /tests | |
| parent | 5b0297464efc131beb7be84fa7a02b9a8670b5dd (diff) | |
Improved figure numbering, labelling and referencing (#491)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ref/meta/figure.png | bin | 26011 -> 103112 bytes | |||
| -rw-r--r-- | tests/typ/meta/counter.typ | 10 | ||||
| -rw-r--r-- | tests/typ/meta/figure.typ | 80 | ||||
| -rw-r--r-- | tests/typ/meta/query.typ | 2 |
4 files changed, 87 insertions, 5 deletions
diff --git a/tests/ref/meta/figure.png b/tests/ref/meta/figure.png Binary files differindex c1b518d3..a86b4d6d 100644 --- a/tests/ref/meta/figure.png +++ b/tests/ref/meta/figure.png 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.], ) <tab-complex> + +--- + +// Testing figures with and without caption +#figure( + table( + columns: 2, + [First cylinder], + image("/cylinder.svg", height: 3cm), + ) +) <fig-image-in-table-no-caption> + +#figure( + table( + columns: 2, + [Second cylinder], + image("/cylinder.svg", height: 3cm), + ), + caption: "A table containing images." +) <fig-image-in-table> + +--- + +// 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", +) <fig-formula> + +#figure( + $a^2 + b^2 = c^2$, + supplement: "Theorem", + kind: "theorem", + caption: "Another Pythagoras' theorem.", + numbering: none, +) <fig-formula> + +#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], ) |
