Skip to content

Instantly share code, notes, and snippets.

@floffy-f
Last active June 30, 2024 16:47
Show Gist options
  • Select an option

  • Save floffy-f/87d536a529d2b243d28521adaa06fafb to your computer and use it in GitHub Desktop.

Select an option

Save floffy-f/87d536a529d2b243d28521adaa06fafb to your computer and use it in GitHub Desktop.
Colored block for theorems in Typst
#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