Refactor handout.typ
All checks were successful
CI / Typos (push) Successful in 30s
CI / Typst formatting (push) Successful in 6s
CI / Build (push) Successful in 11m21s

Reviewed-on: #7
Co-authored-by: Mark <mark@betalupi.com>
Co-committed-by: Mark <mark@betalupi.com>
This commit is contained in:
2025-01-24 17:59:56 -08:00
committed by Mark
parent 334b28ed94
commit 7b62526a5c
10 changed files with 402 additions and 306 deletions

View File

@ -0,0 +1,56 @@
#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),
),
),
),
)
}