diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-09-25 10:26:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-25 08:26:41 +0000 |
| commit | e25389a85e2c4bb7bab5f5d68ab148395704960d (patch) | |
| tree | 1323af9efce63f9a8f412312ebe87e45bb87a60a /tests/suite | |
| parent | fd449f3e08df716d94d79f3f46ff3960e9933d0c (diff) | |
New flow layout, with multi-column floats (#5017)
Diffstat (limited to 'tests/suite')
| -rw-r--r-- | tests/suite/introspection/query.typ | 4 | ||||
| -rw-r--r-- | tests/suite/layout/align.typ | 8 | ||||
| -rw-r--r-- | tests/suite/layout/columns.typ | 7 | ||||
| -rw-r--r-- | tests/suite/layout/container.typ | 61 | ||||
| -rw-r--r-- | tests/suite/layout/flow/flow.typ | 13 | ||||
| -rw-r--r-- | tests/suite/layout/flow/footnote.typ (renamed from tests/suite/model/footnote.typ) | 114 | ||||
| -rw-r--r-- | tests/suite/layout/flow/place-float.typ | 83 | ||||
| -rw-r--r-- | tests/suite/layout/flow/place-flush.typ | 29 | ||||
| -rw-r--r-- | tests/suite/layout/flow/place.typ | 290 | ||||
| -rw-r--r-- | tests/suite/model/cite.typ | 3 | ||||
| -rw-r--r-- | tests/suite/model/figure.typ | 36 |
11 files changed, 512 insertions, 136 deletions
diff --git a/tests/suite/introspection/query.typ b/tests/suite/introspection/query.typ index b078863e..ddb518f5 100644 --- a/tests/suite/introspection/query.typ +++ b/tests/suite/introspection/query.typ @@ -25,10 +25,10 @@ #outline() = Introduction -#v(1cm) +#lines(1) = Background -#v(2cm) +#lines(2) = Approach diff --git a/tests/suite/layout/align.typ b/tests/suite/layout/align.typ index 61b79975..c4ed9ab9 100644 --- a/tests/suite/layout/align.typ +++ b/tests/suite/layout/align.typ @@ -140,3 +140,11 @@ To the right! Where the sunlight peeks behind the mountain. // Test right-aligning a line and a rectangle. #align(right, line(length: 30%)) #align(right, rect()) + +--- issue-2213-align-fr --- +// Test a mix of alignment and fr units (fr wins). +#set page(height: 80pt) +A +#v(1fr) +B +#align(bottom + right)[C] diff --git a/tests/suite/layout/columns.typ b/tests/suite/layout/columns.typ index 87a9f773..b86b798b 100644 --- a/tests/suite/layout/columns.typ +++ b/tests/suite/layout/columns.typ @@ -122,3 +122,10 @@ Hallo = B Text ] + +--- colbreak-weak --- +#set page(columns: 2) +#colbreak(weak: true) +A +#colbreak(weak: true) +B diff --git a/tests/suite/layout/container.typ b/tests/suite/layout/container.typ index 9ce3dc7d..508f1a36 100644 --- a/tests/suite/layout/container.typ +++ b/tests/suite/layout/container.typ @@ -18,10 +18,41 @@ Apart #block(width: 50%, height: 60%, fill: blue) ] ---- box-width-fr --- +--- box-fr-width --- // Test fr box. Hello #box(width: 1fr, rect(height: 0.7em, width: 100%)) World +--- block-fr-height --- +#set page(height: 100pt) +#rect(height: 10pt, width: 100%) +#align(center, block(height: 1fr, width: 20pt, stroke: 1pt)) +#rect(height: 10pt, width: 100%) + +--- block-fr-height-auto-width --- +// Test that the fr block can also expand its parent. +#set page(height: 100pt) +#set align(center) +#block(inset: 5pt, stroke: green)[ + #rect(height: 10pt) + #block(height: 1fr, stroke: 1pt, inset: 5pt)[ + #set align(center + horizon) + I am the widest + ] + #rect(height: 10pt) +] + +--- block-fr-height-first-child --- +// Test that block spacing is not trimmed if only an fr block precedes it. +#set page(height: 100pt) +#rect(height: 1fr) +#rect() + +--- block-fr-height-multiple --- +#set page(height: 100pt) +#rect(height: 1fr) +#rect() +#block(height: 1fr, line(length: 100%, angle: 90deg)) + --- block-multiple-pages --- // Test block over multiple pages. #set page(height: 60pt) @@ -121,6 +152,34 @@ Paragraph #show bibliography: none #bibliography("/assets/bib/works.bib") +--- block-sticky --- +#set page(height: 100pt) +#lines(3) +#block(sticky: true)[D] +#block(sticky: true)[E] +F + +--- block-sticky-alone --- +#set page(height: 50pt) +#block(sticky: true)[A] + +--- block-sticky-many --- +#set page(height: 80pt) +#set block(sticky: true) +#block[A] +#block[B] +#block[C] +#block[D] +E +#block[F] +#block[G] + +--- block-sticky-colbreak --- +A +#block(sticky: true)[B] +#colbreak() +C + --- box-clip-rect --- // Test box clipping with a rectangle Hello #box(width: 1em, height: 1em, clip: false)[#rect(width: 3em, height: 3em, fill: red)] diff --git a/tests/suite/layout/flow/flow.typ b/tests/suite/layout/flow/flow.typ index 88075c5b..fcbc005b 100644 --- a/tests/suite/layout/flow/flow.typ +++ b/tests/suite/layout/flow/flow.typ @@ -55,9 +55,6 @@ --- issue-3641-float-loop --- // Flow layout should terminate! -// -// This is not yet ideal: The heading should not move to the second page, but -// that's a separate bug and not a regression. #set page(height: 40pt) = Heading @@ -69,3 +66,13 @@ #metadata(none) #v(10pt, weak: true) Hi + +--- issue-3866-block-migration --- +#set page(height: 120pt) +#set text(costs: (widow: 0%, orphan: 0%)) +#v(50pt) +#columns(2)[ + #lines(6) + #block(rect(width: 80%, height: 80pt), breakable: false) + #lines(6) +] diff --git a/tests/suite/model/footnote.typ b/tests/suite/layout/flow/footnote.typ index 41091228..f7722e15 100644 --- a/tests/suite/model/footnote.typ +++ b/tests/suite/layout/flow/footnote.typ @@ -9,16 +9,12 @@ A#footnote[A] \ A #footnote[A] --- footnote-nested --- -// Test nested footnotes. -First \ -Second #footnote[A, #footnote[B, #footnote[C]]] \ -Third #footnote[D, #footnote[E]] \ -Fourth - ---- footnote-nested-same-frame --- // Currently, numbers a bit out of order if a nested footnote ends up in the // same frame as another one. :( -#footnote[A, #footnote[B]], #footnote[C] +First \ +Second #footnote[A, #footnote[B, #footnote[C]]] +Third #footnote[D, #footnote[E]] \ +Fourth #footnote[F] --- footnote-entry --- // Test customization. @@ -48,18 +44,94 @@ Beautiful footnotes. #footnote[Wonderful, aren't they?] #lines(6) #footnote[V] // 5 ---- footnote-in-columns --- -// Test footnotes in columns, even those that are not enabled via `set page`. +--- footnote-break-across-pages-block --- +#set page(height: 100pt) +#block[ + #lines(3) #footnote(lines(6, "1")) + #footnote[Y] + #footnote[Z] +] + +--- footnote-break-across-pages-float --- +#set page(height: 180pt) + +#lines(5) + +#place( + bottom, + float: true, + rect(height: 50pt, width: 100%, { + footnote(lines(6, "1")) + footnote(lines(2, "I")) + }) +) + +#lines(5) + +--- footnote-break-across-pages-nested --- #set page(height: 120pt) -#align(center, strong[Title]) +#block[ + #lines(4) + #footnote[ + #lines(6, "1") + #footnote(lines(3, "I")) + ] +] + +--- footnote-in-columns --- +#set page(height: 120pt, columns: 2) + +#place( + top + center, + float: true, + scope: "page", + clearance: 12pt, + strong[Title], +) -#show: columns.with(2) #lines(3) #footnote(lines(4, "1")) #lines(2) #footnote(lines(2, "1")) +--- footnote-in-list --- +#set page(height: 120pt) + +- A #footnote[a] +- B #footnote[b] +- C #footnote[c] +- D #footnote[d] +- E #footnote[e] +- F #footnote[f] +- G #footnote[g] + +--- footnote-block-at-end --- +#set page(height: 50pt) +A +#block(footnote[hello]) + +--- footnote-float-priority --- +#set page(height: 100pt) + +#lines(3) + +#place( + top, + float: true, + rect(height: 40pt) +) + +#block[ + V + #footnote[1] + #footnote[2] + #footnote[3] + #footnote[4] +] + +#lines(5) + --- footnote-in-caption --- // Test footnote in caption. Read the docs #footnote[https://typst.app/docs]! @@ -71,6 +143,15 @@ Read the docs #footnote[https://typst.app/docs]! ) More #footnote[just for ...] footnotes #footnote[... testing. :)] +--- footnote-in-place --- +A +#place(top + right, footnote[A]) +#figure( + placement: bottom, + caption: footnote[B], + rect(), +) + --- footnote-duplicate --- // Test duplicate footnotes. #let lang = footnote[Languages.] @@ -105,6 +186,10 @@ A #footnote(lines(6, "1")) A footnote #footnote[Hi]<fn> \ A reference to it @fn +--- footnote-self-ref --- +// Error: 2-16 footnote cannot reference itself +#footnote(<fn>) <fn> + --- footnote-ref-multiple --- // Multiple footnotes are refs First #footnote[A]<fn1> \ @@ -163,10 +248,7 @@ Ref @fn .map(v => upper(v) + footnote(v)) ) ---- issue-multiple-footnote-in-one-line --- -// Test that the logic that keeps footnote entry together with -// their markers also works for multiple footnotes in a single -// line. +--- footnote-multiple-in-one-line --- #set page(height: 100pt) #v(50pt) A #footnote[a] diff --git a/tests/suite/layout/flow/place-float.typ b/tests/suite/layout/flow/place-float.typ deleted file mode 100644 index 50a8a112..00000000 --- a/tests/suite/layout/flow/place-float.typ +++ /dev/null @@ -1,83 +0,0 @@ ---- place-float-flow-around --- -#set page(height: 80pt) -#set place(float: true) -#place(bottom + center, rect(height: 20pt)) -#lines(4) - ---- place-float-queued --- -#set page(height: 180pt) -#set figure(placement: auto) - -#figure(rect(height: 60pt), caption: [I]) -#figure(rect(height: 40pt), caption: [II]) -#figure(rect(), caption: [III]) -#figure(rect(), caption: [IV]) -A - ---- place-float-align-auto --- -#set page(height: 140pt) -#set place(clearance: 5pt) -#set place(auto, float: true) - -#place(rect[A]) -#place(rect[B]) -1 \ 2 -#place(rect[C]) -#place(rect[D]) - ---- place-float-in-column-align-auto --- -#set page(height: 150pt, columns: 2) -#set place(auto, float: true, clearance: 10pt) -#set rect(width: 75%) - -#place(rect[I]) -#place(rect[II]) -#place(rect[III]) -#place(rect[IV]) - -#lines(6) - -#place(rect[V]) - ---- place-float-in-column-queued --- -#set page(height: 100pt, columns: 2) -#set place(float: true, clearance: 10pt) -#set rect(width: 75%) -#set text(costs: (widow: 0%, orphan: 0%)) - -#lines(3) - -#place(top, rect[I]) -#place(top, rect[II]) -#place(bottom, rect[III]) - -#lines(3) - ---- place-float-missing --- -// Error: 2-20 automatic positioning is only available for floating placement -// Hint: 2-20 you can enable floating placement with `place(float: true, ..)` -#place(auto)[Hello] - ---- place-float-center-horizon --- -// Error: 2-45 floating placement must be `auto`, `top`, or `bottom` -#place(center + horizon, float: true)[Hello] - ---- place-float-horizon --- -// Error: 2-36 floating placement must be `auto`, `top`, or `bottom` -#place(horizon, float: true)[Hello] - ---- place-float-default --- -// Error: 2-27 floating placement must be `auto`, `top`, or `bottom` -#place(float: true)[Hello] - ---- place-float-right --- -// Error: 2-34 floating placement must be `auto`, `top`, or `bottom` -#place(right, float: true)[Hello] - ---- issue-2595-float-overlap --- -#set page(height: 80pt) - -1 -#place(auto, float: true, block(height: 100%, width: 100%, fill: aqua)) -#place(auto, float: true, block(height: 100%, width: 100%, fill: red)) -#lines(7) diff --git a/tests/suite/layout/flow/place-flush.typ b/tests/suite/layout/flow/place-flush.typ deleted file mode 100644 index 8f55a6fd..00000000 --- a/tests/suite/layout/flow/place-flush.typ +++ /dev/null @@ -1,29 +0,0 @@ ---- place-flush --- -#set page(height: 120pt) -#let floater(align, height) = place( - align, - float: true, - rect(width: 100%, height: height), -) - -#floater(top, 30pt) -A - -#floater(bottom, 50pt) -#place.flush() -B // Should be on the second page. - ---- place-flush-figure --- -#set page(height: 120pt) -#let floater(align, height, caption) = figure( - placement: align, - caption: caption, - rect(width: 100%, height: height), -) - -#floater(top, 30pt)[I] -A - -#floater(bottom, 50pt)[II] -#place.flush() -B // Should be on the second page. diff --git a/tests/suite/layout/flow/place.typ b/tests/suite/layout/flow/place.typ index f3231735..dc655ec5 100644 --- a/tests/suite/layout/flow/place.typ +++ b/tests/suite/layout/flow/place.typ @@ -70,6 +70,288 @@ Second #line(length: 50pt) ] +--- place-float-flow-around --- +#set page(height: 80pt) +#set place(float: true) +#place(bottom + center, rect(height: 20pt)) +#lines(4) + +--- place-float-queued --- +#set page(height: 180pt) +#set figure(placement: auto) + +#figure(rect(height: 60pt), caption: [I]) +#figure(rect(height: 40pt), caption: [II]) +#figure(rect(), caption: [III]) +A +#figure(rect(), caption: [IV]) + +--- place-float-align-auto --- +#set page(height: 140pt) +#set place(auto, float: true, clearance: 5pt) + +#place(rect[A]) +#place(rect[B]) +1 \ 2 +#place(rect[C]) +#place(rect[D]) + +--- place-float-delta --- +#place(top + center, float: true, dx: 10pt, rect[I]) +A +#place(bottom + center, float: true, dx: -10pt, rect[II]) + +--- place-float-flow-size --- +#set page(width: auto, height: auto) +#set place(float: true, clearance: 5pt) + +#place(bottom, rect(width: 80pt, height: 10pt)) +#place(top + center, rect(height: 20pt)) +#align(center)[A] +#pagebreak() +#align(center)[B] +#place(bottom, scope: "page", rect(height: 10pt)) + +--- place-float-flow-size-alone --- +#set page(width: auto, height: auto) +#set place(float: true, clearance: 5pt) +#place(auto)[A] + +--- place-float-fr --- +#set page(height: 120pt, columns: 2) +#set place(float: true, clearance: 10pt) +#set rect(width: 70%) + +#place(top + center, rect[I]) +#place(bottom + center, scope: "page", rect[II]) + +A +#v(1fr) +B +#colbreak() +C +#align(bottom)[D] + +--- place-float-rel-sizing --- +#set page(height: 100pt, columns: 2) +#set place(float: true, clearance: 10pt) +#set rect(width: 70%) + +#place(top + center, scope: "page", rect[I]) +#place(top + center, rect[II]) + +// This test result is not ideal: The first column takes 30% of the full page, +// while the second takes 30% of the remaining space since there is no concept +// of `full` for followup pages. +#set align(bottom) +#rect(width: 100%, height: 30%) +#rect(width: 100%, height: 30%) + +--- place-float-block-backlog --- +#set page(height: 100pt) +#v(60pt) +#place(top, float: true, rect()) +#list(.."ABCDEFGHIJ".clusters()) + +--- place-float-clearance-empty --- +// Check that we don't require space for clearance if there is no content. +#set page(height: 100pt) +#v(1fr) +#table( + columns: (1fr, 1fr), + lines(2), + [], + lines(8), + place(auto, float: true, block(width: 100%, height: 100%, fill: aqua)) +) + + +--- place-float-column-align-auto --- +#set page(height: 150pt, columns: 2) +#set place(auto, float: true, clearance: 10pt) +#set rect(width: 75%) + +#place(rect[I]) +#place(rect[II]) +#place(rect[III]) +#place(rect[IV]) + +#lines(6) + +#place(rect[V]) +#place(rect[VI]) + +--- place-float-column-queued --- +#set page(height: 100pt, columns: 2) +#set place(float: true, clearance: 10pt) +#set rect(width: 75%) +#set text(costs: (widow: 0%, orphan: 0%)) + +#lines(3) + +#place(top, rect[I]) +#place(top, rect[II]) +#place(bottom, rect[III]) + +#lines(3) + +--- place-float-twocolumn --- +#set page(height: 100pt, columns: 2) +#set place(float: true, clearance: 10pt) +#set rect(width: 70%) + +#place(top + center, scope: "page", rect[I]) +#place(top + center, rect[II]) +#lines(4) +#place(top + center, rect[III]) +#block(width: 100%, height: 70pt, fill: conifer) +#place(bottom + center, scope: "page", rect[IV]) +#place(bottom + center, rect[V]) +#v(1pt, weak: true) +#block(width: 100%, height: 60pt, fill: aqua) + +--- place-float-twocolumn-queued --- +#set page(height: 100pt, columns: 2) +#set place(float: true, scope: "page", clearance: 10pt) +#let t(align, fill) = place(top + align, rect(fill: fill, height: 25pt)) + +#t(left, aqua) +#t(center, forest) +#t(right, conifer) +#lines(7) + +--- place-float-twocolumn-align-auto --- +#set page(height: 100pt, columns: 2) +#set place(float: true, clearance: 10pt) +#set rect(width: 70%) + +#place(auto, scope: "page", rect[I]) // Should end up `top` +#lines(4) +#place(auto, scope: "page", rect[II]) // Should end up `bottom` +#lines(4) + +--- place-float-twocolumn-fits --- +#set page(height: 100pt, columns: 2) +#set place(float: true, clearance: 10pt) +#set rect(width: 70%) + +#lines(6) +#place(auto, scope: "page", rect[I]) +#lines(12, "1") + +--- place-float-twocolumn-fits-not --- +#set page(height: 100pt, columns: 2) +#set place(float: true, clearance: 10pt) +#set rect(width: 70%) + +#lines(10) +#place(auto, scope: "page", rect[I]) +#lines(10, "1") + +--- place-float-threecolumn --- +#set page(height: 100pt, columns: 3) +#set place(float: true, clearance: 10pt) +#set rect(width: 70%) + +#place(bottom + center, scope: "page", rect[I]) +#lines(21) +#place(top + center, scope: "page", rect[II]) + +--- place-float-threecolumn-block-backlog --- +#set page(height: 100pt, columns: 3) +#set place(float: true, clearance: 10pt) +#set rect(width: 70%) + +// The most important part of this test is that we get the backlog of the +// conifer (green) block right. +#place(top + center, scope: "page", rect[I]) +#block(fill: aqua, width: 100%, height: 70pt) +#block(fill: conifer, width: 100%, height: 160pt) +#place(bottom + center, scope: "page", rect[II]) +#place(top, rect(height: 40%)[III]) +#block(fill: yellow, width: 100%, height: 60pt) + +--- place-float-counter --- +#let c = counter("c") +#let cd = context c.display() + +#set page( + height: 100pt, + margin: (y: 20pt), + header: [H: #cd], + footer: [F: #cd], + columns: 2, +) + +#let t(align, scope: "column", n) = place( + align, + float: true, + scope: scope, + clearance: 10pt, + line(length: 100%) + c.update(n), +) + +#t(bottom, 6) +#cd +#t(top, 3) +#colbreak() +#cd +#t(scope: "page", bottom, 11) +#colbreak() +#cd +#t(top, 12) + +--- place-float-missing --- +// Error: 2-20 automatic positioning is only available for floating placement +// Hint: 2-20 you can enable floating placement with `place(float: true, ..)` +#place(auto)[Hello] + +--- place-float-center-horizon --- +// Error: 2-45 vertical floating placement must be `auto`, `top`, or `bottom` +#place(center + horizon, float: true)[Hello] + +--- place-float-horizon --- +// Error: 2-36 vertical floating placement must be `auto`, `top`, or `bottom` +#place(horizon, float: true)[Hello] + +--- place-float-default --- +// Error: 2-27 vertical floating placement must be `auto`, `top`, or `bottom` +#place(float: true)[Hello] + +--- place-float-right --- +// Error: 2-34 vertical floating placement must be `auto`, `top`, or `bottom` +#place(right, float: true)[Hello] + +--- place-flush --- +#set page(height: 120pt) +#let floater(align, height) = place( + align, + float: true, + rect(width: 100%, height: height), +) + +#floater(top, 30pt) +A + +#floater(bottom, 50pt) +#place.flush() +B // Should be on the second page. + +--- place-flush-figure --- +#set page(height: 120pt) +#let floater(align, height, caption) = figure( + placement: align, + caption: caption, + rect(width: 100%, height: height), +) + +#floater(top, 30pt)[I] +A + +#floater(bottom, 50pt)[II] +#place.flush() +B // Should be on the second page. + --- issue-place-base --- // Test that placement is relative to container and not itself. #set page(height: 80pt, margin: 0pt) @@ -98,3 +380,11 @@ Paragraph after float. Paragraph before place. #place(rect()) Paragraph after place. + +--- issue-2595-float-overlap --- +#set page(height: 80pt) + +1 +#place(auto, float: true, block(height: 100%, width: 100%, fill: aqua)) +#place(auto, float: true, block(height: 100%, width: 100%, fill: red)) +#lines(7) diff --git a/tests/suite/model/cite.typ b/tests/suite/model/cite.typ index ffbd3b52..f69fe9f4 100644 --- a/tests/suite/model/cite.typ +++ b/tests/suite/model/cite.typ @@ -102,8 +102,7 @@ B #cite(<netwok>) #cite(<arrgh>). // Everything moves to the second page because we want to keep the line and // its footnotes together. -#footnote[@netwok] -#footnote[A] +#footnote[@netwok \ A] #show bibliography: none #bibliography("/assets/bib/works.bib") diff --git a/tests/suite/model/figure.typ b/tests/suite/model/figure.typ index 13e94481..d71d92e3 100644 --- a/tests/suite/model/figure.typ +++ b/tests/suite/model/figure.typ @@ -41,6 +41,42 @@ We can clearly see that @fig-cylinder and caption: "A table containing images." ) <fig-image-in-table> +--- figure-placement --- +#set page(height: 160pt, columns: 2) +#set place(clearance: 10pt) + +#lines(4) + +#figure( + placement: auto, + scope: "page", + caption: [I], + rect(height: 15pt, width: 80%), +) + +#figure( + placement: bottom, + caption: [II], + rect(height: 15pt, width: 80%), +) + +#lines(2) + +#figure( + placement: bottom, + caption: [III], + rect(height: 25pt, width: 80%), +) + +#figure( + placement: auto, + scope: "page", + caption: [IV], + rect(width: 80%), +) + +#lines(15) + --- figure-theorem --- // Testing show rules with figures with a simple theorem display #show figure.where(kind: "theorem"): it => { |
