From ecb70b9ea896c869eb80998259abcc9454e41c96 Mon Sep 17 00:00:00 2001 From: Mark Date: Sun, 9 Feb 2025 21:58:52 -0800 Subject: [PATCH] Tweak lib --- lib/typst/local/handout/0.1.0/lib.typ | 8 ++++- lib/typst/local/handout/0.1.0/solution.typ | 35 +++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/lib/typst/local/handout/0.1.0/lib.typ b/lib/typst/local/handout/0.1.0/lib.typ index 12485c0..43e503e 100755 --- a/lib/typst/local/handout/0.1.0/lib.typ +++ b/lib/typst/local/handout/0.1.0/lib.typ @@ -4,7 +4,13 @@ // All functions that maybe used by client code are listed here #import "misc.typ": * #import "object.typ": problem, definition, theorem, example, remark, generic -#import "solution.typ": if_solutions, if_no_solutions, solution +#import "solution.typ": ( + if_solutions, + if_no_solutions, + if_solutions_else, + solution, + instructornote, +) /// Main handout wrapper. diff --git a/lib/typst/local/handout/0.1.0/solution.typ b/lib/typst/local/handout/0.1.0/solution.typ index abb54b2..9f611cb 100755 --- a/lib/typst/local/handout/0.1.0/solution.typ +++ b/lib/typst/local/handout/0.1.0/solution.typ @@ -1,4 +1,4 @@ -#import "misc.typ": ored +#import "misc.typ": ored, oteal /// If false, hide instructor info. /// @@ -27,6 +27,10 @@ if not show_solutions { content } } +#let if_solutions_else(if_yes, if_no) = { + if show_solutions { if_yes } else { if_no } +} + #let solution(content) = { if_solutions( align( @@ -54,3 +58,32 @@ ), ) } + +#let instructornote(content) = { + let c = oteal + if_solutions( + align( + center, + stack( + block( + width: 100%, + breakable: false, + fill: c, + stroke: c + 2pt, + inset: 1.5mm, + align(left, text(fill: white, weight: "bold", [Instructor note:])), + ), + + block( + width: 100%, + height: auto, + breakable: false, + fill: c.lighten(80%).desaturate(10%), + stroke: c + 2pt, + inset: 3mm, + align(left, content), + ), + ), + ), + ) +}