Refactor handout.typ
Reviewed-on: #7 Co-authored-by: Mark <mark@betalupi.com> Co-committed-by: Mark <mark@betalupi.com>
This commit is contained in:
56
lib/typst/local/handout/0.1.0/solution.typ
Executable file
56
lib/typst/local/handout/0.1.0/solution.typ
Executable 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),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user