oxedyne/fe2o3/fe2o3_austenite/tests/fixtures/incremental/counters_context.typ
1.6 KiB, 1 run
created by r1870400018:67947, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | // Counters and `context` reads: a page counter and its final value in the footer, a custom counter stepped through the |
| 2 | // text, a state updated and read back, and a read of the page the paragraph itself lands on. |
| 3 | #set page(width: 220pt, height: 130pt, margin: 16pt, |
| 4 | footer: context [Page #counter(page).display() of #counter(page).final().first()]) |
| 5 | #set text(size: 9pt) |
| 6 | #let note = counter("note") |
| 7 | #let seen = state("seen", 0) |
| 8 | |
| 9 | First paragraph. #note.step() #seen.update(n => n + 1) It opens the account and steps the counter once, so that the later reads have something to count, and it goes on long enough to fill some lines. |
| 10 | |
| 11 | #context [Note counter here: #note.get().first(), final #note.final().first(), seen #seen.get(), seen at the end #seen.final().] |
| 12 | |
| 13 | Second paragraph. #note.step() #seen.update(n => n + 1) It steps both again and carries on with the sort of ordinary prose that fills a page, so that the counters move across a page break in the middle of it. |
| 14 | |
| 15 | Third paragraph. #note.step() #seen.update(n => n + 1) A third step, then more text to take the document on towards its second and third pages and keep the flow going. |
| 16 | |
| 17 | #context [This paragraph is on page #here().page() of #counter(page).final().first(), counter #note.get().first().] |
| 18 | |
| 19 | Fourth paragraph. #note.step() #seen.update(n => n + 1) A fourth step with the text that goes with it, more or less the same as before so that the pages fill at a steady rate. |
| 20 | |
| 21 | Fifth paragraph. #note.step() #seen.update(n => n + 1) The fifth step, and then the closing read of everything that has been counted. |
| 22 | |
| 23 | #context [Closing read: note #note.get().first() of #note.final().first(), seen #seen.final().] |