2025-01-24 17:46:07 -08:00

57 lines
1.2 KiB
Typst
Executable File

#import "misc.typ": ored
/// If false, hide instructor info.
///
/// Compile with the following command to hide solutions:
/// `typst compile main.typ --input show_solutions=false`
///
/// Solutions are shown by default. This behavior
/// is less surprising than hiding content by default.
#let show_solutions = {
if "show_solutions" in sys.inputs {
// Show solutions unless they're explicitly disabled
not (
sys.inputs.show_solutions == "false" or sys.inputs.show_solutions == "no"
)
} else {
// Show solutions by default
true
}
}
#let if_solutions(content) = {
if show_solutions { content }
}
#let if_no_solutions(content) = {
if not show_solutions { content }
}
#let solution(content) = {
if_solutions(
align(
center,
stack(
block(
width: 100%,
breakable: false,
fill: ored,
stroke: ored + 2pt,
inset: 1.5mm,
align(left, text(fill: white, weight: "bold", [Solution:])),
),
block(
width: 100%,
height: auto,
breakable: false,
fill: ored.lighten(80%).desaturate(10%),
stroke: ored + 2pt,
inset: 3mm,
align(left, content),
),
),
),
)
}