Can't find a nice license text, but consider it public domain, CC0, etc. to the extent I am able to. It's just a few lines of code.
-
-
Save FriendlyUser/c6a3350c1f6519b78b3e1d66ce9b6a4e to your computer and use it in GitHub Desktop.
Titled & stacking textbox for Typst
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
| // todo: key this by the provided label or just use dependency injection | |
| #let this-counter = counter("info-box") | |
| #let info-box( | |
| title: none, | |
| sections: none, | |
| label: none, | |
| caption: none, | |
| radius: 3pt, | |
| inset: 16pt, | |
| outset: 0pt, | |
| fill: luma(45), | |
| ) = { | |
| set block(spacing: 0pt) | |
| let title-radius = radius | |
| if sections != none { | |
| title-radius = (top: radius) | |
| } | |
| pad( | |
| y: inset, | |
| [ | |
| #pad( | |
| x: outset, | |
| rect( | |
| width: 100%, | |
| inset: 0pt, | |
| stroke: fill, | |
| radius: radius, | |
| [ | |
| #if title != none { | |
| block( | |
| width: 100%, | |
| radius: title-radius, | |
| fill: fill, | |
| pad( | |
| inset, | |
| par( | |
| justify: false, | |
| text( | |
| hyphenate: false, | |
| white, | |
| title | |
| ) | |
| ) | |
| ) | |
| ) | |
| } | |
| #if sections != none { | |
| let i = 0 | |
| for section in sections { | |
| if i > 0 { | |
| line(length: 100%) | |
| } | |
| pad( | |
| inset, | |
| section | |
| ) | |
| i += 1 | |
| } | |
| } | |
| ] | |
| ) | |
| ) | |
| #if caption != none { | |
| align( | |
| center, | |
| pad( | |
| 12pt, | |
| [ | |
| #if label != none { | |
| label | |
| } | |
| #this-counter.display(): | |
| #caption | |
| ] | |
| ) | |
| ) | |
| this-counter.step() | |
| } | |
| ] | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment