diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-08-26 19:17:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-26 17:17:58 +0000 |
| commit | 4365e18454af4f8f53fe1198182cb5dc8f3d628e (patch) | |
| tree | fe37649cec71b916d5119a033028e3f620247209 /tests/suite/introspection | |
| parent | cb98eec60924a41889988644e5122d2e13eccbf1 (diff) | |
Improve realization and page layout (#4840)
Diffstat (limited to 'tests/suite/introspection')
| -rw-r--r-- | tests/suite/introspection/counter.typ | 40 | ||||
| -rw-r--r-- | tests/suite/introspection/locate.typ | 90 |
2 files changed, 130 insertions, 0 deletions
diff --git a/tests/suite/introspection/counter.typ b/tests/suite/introspection/counter.typ index 0d2be6e2..8cae32a4 100644 --- a/tests/suite/introspection/counter.typ +++ b/tests/suite/introspection/counter.typ @@ -62,6 +62,46 @@ At Beta, it was #context { #counter(page).update(1) #lorem(20) +--- counter-page-footer-before-set-page --- +#set page(numbering: "1", margin: (bottom: 20pt)) +A +#pagebreak() +#counter(page).update(5) +#set page(fill: aqua) +B + +--- counter-page-header-before-set-page --- +#set page(numbering: "1", number-align: top + center, margin: (top: 20pt)) +A +#counter(page).update(4) +#set page(fill: aqua) +B + +--- counter-page-between-pages --- +// The update happens conceptually between the pages. +#set page(numbering: "1", margin: (bottom: 20pt)) +A +#pagebreak() +#counter(page).update(5) +#set page(number-align: top + center, margin: (top: 20pt, bottom: 10pt)) +B + +--- counter-page-header-only-update --- +// Header should not be affected by default. +// To affect it, put the counter update before the `set page`. +#set page( + numbering: "1", + number-align: top + center, + margin: (top: 20pt), +) + +#counter(page).update(5) + +--- counter-page-footer-only-update --- +// Footer should be affected by default. +#set page(numbering: "1 / 1", margin: (bottom: 20pt)) +#counter(page).update(5) + --- counter-figure --- // Count figures. #figure(numbering: "A", caption: [Four 'A's], kind: image, supplement: "Figure")[_AAAA!_] diff --git a/tests/suite/introspection/locate.typ b/tests/suite/introspection/locate.typ index b3a77fde..18611dde 100644 --- a/tests/suite/introspection/locate.typ +++ b/tests/suite/introspection/locate.typ @@ -37,3 +37,93 @@ // Error: 10-25 selector matches multiple elements #context locate(heading) + +--- locate-between-pages --- +// Test locating tags that are before or between pages. +#set page(height: 30pt) +#context [ + // Before the first page. + // (= at the very start of the first page, before the header) + #test(locate(<a>).position(), (page: 1, x: 0pt, y: 0pt)) + + // On the first page. + #test(locate(<b>).position(), (page: 1, x: 10pt, y: 10pt)) + + // Between the two pages. + // (= at the very start of the first page, before the header) + #test(locate(<c>).position(), (page: 2, x: 0pt, y: 0pt)) + + // After the last page. + // (= at the very end of the last page, after the footer) + #test(locate(<d>).position(), (page: 2, x: 0pt, y: 30pt)) + #test(locate(<e>).position(), (page: 2, x: 0pt, y: 30pt)) +] + +#metadata(none) <a> +#pagebreak(weak: true) +#metadata(none) <b> +A +#pagebreak() +#metadata(none) <c> +#pagebreak(weak: true) +B +#pagebreak(weak: true) +#metadata(none) <d> +#pagebreak(weak: true) +#metadata(none) <e> + +--- issue-4029-locate-after-spacing --- +#set page(margin: 10pt) +#show heading: it => v(40pt) + it + += Introduction +#context test( + locate(heading).position(), + (page: 1, x: 10pt, y: 50pt), +) + + +--- issue-4029-locate-after-pagebreak --- +#set page(margin: 10pt) +#show heading: it => pagebreak() + it + += Introduction +#context test( + locate(heading).position(), + (page: 2, x: 10pt, y: 10pt), +) + +--- issue-4029-locate-after-par-and-pagebreak --- +// Ensure that the heading's tag isn't stuck at the end of the paragraph. +#set page(margin: 10pt) +Par +#show heading: it => pagebreak() + it += Introduction +#context test(locate(heading).page(), 2) + +--- issue-1886-locate-after-metadata --- +#show heading: it => { + metadata(it.label) + pagebreak(weak: true, to: "odd") + it +} + +Hi += Hello <hello> += World <world> + +// The metadata's position does not migrate to the next page, but the heading's +// does. +#context { + test(locate(metadata.where(value: <hello>)).page(), 1) + test(locate(<hello>).page(), 3) + test(locate(metadata.where(value: <world>)).page(), 3) + test(locate(<world>).page(), 5) +} + +--- issue-1833-locate-place --- +#set page(height: 60pt) +#context { + place(right + bottom, rect()) + test(here().position(), (page: 1, x: 10pt, y: 10pt)) +} |
