diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-17 11:32:15 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-17 11:45:57 +0100 |
| commit | 312197b276748e1a17258ad21837850f582a467c (patch) | |
| tree | 3fd0c078a2673a98b74bc12b4d654a4c143b4e1f /tests | |
| parent | e8435df5ec718e8ecc8a2ad48e4eb3ddd1f92a72 (diff) | |
Counters
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ref/layout/page-marginals.png | bin | 58546 -> 57998 bytes | |||
| -rw-r--r-- | tests/ref/meta/counter-page.png | bin | 0 -> 9723 bytes | |||
| -rw-r--r-- | tests/ref/meta/counter.png | bin | 0 -> 12724 bytes | |||
| -rw-r--r-- | tests/ref/meta/figure.png | bin | 25146 -> 26011 bytes | |||
| -rw-r--r-- | tests/ref/meta/outline.png | bin | 80518 -> 80513 bytes | |||
| -rw-r--r-- | tests/typ/layout/page-marginals.typ | 10 | ||||
| -rw-r--r-- | tests/typ/meta/counter-page.typ | 9 | ||||
| -rw-r--r-- | tests/typ/meta/counter.typ | 48 | ||||
| -rw-r--r-- | tests/typ/meta/outline.typ | 2 |
9 files changed, 63 insertions, 6 deletions
diff --git a/tests/ref/layout/page-marginals.png b/tests/ref/layout/page-marginals.png Binary files differindex 5ad67ab4..bbe6358e 100644 --- a/tests/ref/layout/page-marginals.png +++ b/tests/ref/layout/page-marginals.png diff --git a/tests/ref/meta/counter-page.png b/tests/ref/meta/counter-page.png Binary files differnew file mode 100644 index 00000000..62f663cc --- /dev/null +++ b/tests/ref/meta/counter-page.png diff --git a/tests/ref/meta/counter.png b/tests/ref/meta/counter.png Binary files differnew file mode 100644 index 00000000..679e748f --- /dev/null +++ b/tests/ref/meta/counter.png diff --git a/tests/ref/meta/figure.png b/tests/ref/meta/figure.png Binary files differindex b39f462f..c1b518d3 100644 --- a/tests/ref/meta/figure.png +++ b/tests/ref/meta/figure.png diff --git a/tests/ref/meta/outline.png b/tests/ref/meta/outline.png Binary files differindex 7bcb971e..5d05b015 100644 --- a/tests/ref/meta/outline.png +++ b/tests/ref/meta/outline.png diff --git a/tests/typ/layout/page-marginals.typ b/tests/typ/layout/page-marginals.typ index 30bd39c1..d8ce9b79 100644 --- a/tests/typ/layout/page-marginals.typ +++ b/tests/typ/layout/page-marginals.typ @@ -1,15 +1,15 @@ #set page( paper: "a8", margin: (x: 15pt, y: 30pt), - header: align(horizon, { + header: { text(eastern)[*Typst*] h(1fr) text(0.8em)[_Chapter 1_] - }), - footer: page => v(5pt) + align(center)[\~ #page \~], - background: n => if n <= 2 { + }, + footer: align(center)[\~ #counter(page).get() \~], + background: counter(page).get(n => if n <= 2 { place(center + horizon, circle(radius: 1cm, fill: luma(90%))) - } + }) ) But, soft! what light through yonder window breaks? It is the east, and Juliet diff --git a/tests/typ/meta/counter-page.typ b/tests/typ/meta/counter-page.typ new file mode 100644 index 00000000..b45a26f3 --- /dev/null +++ b/tests/typ/meta/counter-page.typ @@ -0,0 +1,9 @@ +// Test the page counter. + +#set page(height: 50pt, margin: (bottom: 20pt, rest: 10pt)) +#set page(numbering: "(i)") +#lorem(6) +#pagebreak() +#set page(numbering: "1 / 1") +#counter(page).update(1) +#lorem(20) diff --git a/tests/typ/meta/counter.typ b/tests/typ/meta/counter.typ new file mode 100644 index 00000000..9f6f4c8a --- /dev/null +++ b/tests/typ/meta/counter.typ @@ -0,0 +1,48 @@ +// Test counters. + +--- +// Count with string key. +#let mine = counter("mine!") + +Final: #mine.final() \ +#mine.step() +#mine.step() +First: #mine.get() \ +#mine.update(7) +#mine.both("1 of 1") \ +#mine.step() +#mine.step() +Second: #mine.get("I") +#mine.update(n => n * 2) +#mine.step() + +--- +// Count labels. +#let label = <heya> +#let count = counter(label).get() +#let elem(it) = [#box(it) #label] + +#elem[hey, there!] #count \ +#elem[more here!] #count + +--- +// Count headings. +#set heading(numbering: "1.a.") +#show heading: set text(10pt) +#counter(heading).step() + += Alpha +== Beta +In #counter(heading).get(). + +#set heading(numbering: none) += Gamma +#heading(numbering: "I.")[Delta] + +--- +// 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!_] diff --git a/tests/typ/meta/outline.typ b/tests/typ/meta/outline.typ index 1f882cec..83b2e906 100644 --- a/tests/typ/meta/outline.typ +++ b/tests/typ/meta/outline.typ @@ -1,4 +1,4 @@ -#set page("a7", margin: 20pt, footer: n => align(center, [#n])) +#set page("a7", margin: 20pt, numbering: "1") #set heading(numbering: "(1/a)") #show heading.where(level: 1): set text(12pt) #show heading.where(level: 2): set text(10pt) |
