Last active
June 30, 2024 16:47
-
-
Save floffy-f/87d536a529d2b243d28521adaa06fafb to your computer and use it in GitHub Desktop.
Colored block for theorems in 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
| #let theoremblock(title: [Theorem:], color: green, radius: (top-right: 2pt, bottom-right: 2pt), ..args, body) = { | |
| // The top-title block needs only the | |
| let tr = radius.at( | |
| default: radius.at( | |
| default: radius.at( | |
| default: 0pt, | |
| "right" | |
| ), | |
| "top" | |
| ), | |
| "top-right" | |
| ) | |
| let tl = radius.at( | |
| default: radius.at( | |
| default: radius.at( | |
| default: 0pt, | |
| "top" | |
| ), | |
| "left" | |
| ), | |
| "top-left" | |
| ) | |
| block( | |
| breakable: false, | |
| stack(dir: ttb, | |
| block( | |
| width: 100%, | |
| fill: color.lighten(60%), | |
| inset: (x: 2pt, y: 3pt), | |
| stroke: (left: 1pt+color.lighten(30%)), | |
| radius: ( | |
| top-right: tr, | |
| top-left: tl | |
| ), | |
| text(color.darken(40%), weight: "bold", title) | |
| ), | |
| block( | |
| width: 100%, | |
| fill: color.lighten(90%), | |
| inset: (left: 3%, y: 10%, right: 2%), | |
| stroke: (left: 1pt+color.lighten(30%)), | |
| radius: radius, | |
| ..args, | |
| body | |
| ) | |
| ) | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment