Skip to content

Commit

Permalink
Merge pull request #70 from andreasKroepelin/repeat-last
Browse files Browse the repository at this point in the history
Implement repeat-last
  • Loading branch information
andreasKroepelin committed Aug 21, 2023
2 parents 8484df0 + 5847eb3 commit b5403d9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
16 changes: 14 additions & 2 deletions logic.typ
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,25 @@
}
}

#let alternatives(start: 1, position: bottom + left, ..children) = {
#let alternatives(
start: 1,
position: bottom + left,
repeat-last: false,
..children
) = {
style(styles => {
let sizes = children.pos().map(c => measure(c, styles))
let max-width = calc.max(..sizes.map(sz => sz.width))
let max-height = calc.max(..sizes.map(sz => sz.height))
for (idx, child) in children.pos().enumerate() {
only(start + idx, box(
let last = idx == children.pos().len() - 1
let visible-subslides = if last and repeat-last {
(beginning: start + idx)
} else {
start + idx
}

only(visible-subslides, box(
width: max-width,
height: max-height,
align(position, child)
Expand Down
1 change: 1 addition & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pdf
13 changes: 13 additions & 0 deletions tests/alternatives.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#import "../polylux.typ": *

#set page(paper: "presentation-16-9")

#polylux-slide[
== Test that `repeat-last` works

#alternatives[abc ][def ][ghi ]

#alternatives(repeat-last: true)[jkl ][mno ][this stays ]

#uncover(5)[You can go now.]
]

0 comments on commit b5403d9

Please sign in to comment.