Last active
June 9, 2025 10:30
-
-
Save hongjr03/0a0ffdb20fc9be757cb184191cf41883 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #let bcol(..args) = layout(container => context { | |
| let num-columns = args.pos().first() | |
| let body = args.pos().at(1) | |
| let parent-places = body.children.filter(x => ( | |
| "scope" in x.fields() and x.fields().scope == "parent" | |
| )) | |
| let gutter = if "gutter" in args.named() { args.named().gutter } else { (4% + 0pt).length } | |
| let column-width = (container.width - gutter * (num-columns - 1)) / num-columns | |
| let height = ( | |
| calc.ceil( | |
| ( | |
| ( | |
| measure( | |
| body, | |
| width: column-width, | |
| ).height | |
| + parent-places.map(place => measure(place, width: container.width).height).sum(default: 0pt) * num-columns | |
| - parent-places.map(place => measure(place, width: column-width).height).sum(default: 0pt) | |
| ) | |
| / num-columns | |
| + 0.5em.to-absolute() | |
| ) | |
| / 1em.to-absolute(), | |
| ) | |
| * 1em | |
| ) | |
| block( | |
| height: height, | |
| breakable: true, | |
| columns(num-columns, body, gutter: gutter, ..args.named()), | |
| ) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment