typst-abjaeb/0.0.1/lib.typ
2025-05-14 16:41:21 +02:00

123 lines
2.6 KiB
Typst

//".preamble.typ"
#import "@preview/ctheorems:1.1.3": thmbox, thmrules, thmproof, thmplain
// #let printanswers = true
#let printanswersstate = state("printanswers", false)
#let answers(b) = {
printanswersstate.update(printanswers => b)
}
#let ifprintanswers(thencontent, elsecontent: none) = {
context if printanswersstate.get(){
thencontent
}else{
elsecontent
}
}
#let underlinespace(width) = box(
width: width,
stroke: (bottom: .5pt),
outset: (bottom: 1pt),
)
#let dx = $#h(.2em) d x$
#let häuschen_q = tiling(size: (4mm, 4mm),
//colour: red
)[
#square(
size: 4mm,
fill: none,
stroke: gray,
//colour: gray,
//.conic(..olor.map.rainbow),
)
// #place(line(start: (0%, 0%), end: (0%, 100%)))
// #place(line(start: (0%, 100%), end: (100%, 100%)))
]
#let häuschen_l = tiling(
size: (4mm, 4mm),
)[
#place(line(stroke: gray, start: (0%, 0%), end: (0%, 100%)))
#place(line(stroke: gray, start: (0%, 0%), end: (100%, 0%)))
]
#let fillwithgrid(p) = block(
//fill: häuschen_q,
fill: häuschen_l,
height: p,
width: 100%)[
//Hallo
]
#let exmp = thmbox(
"exmp",
"Beispiel",
fill: rgb("#eee"),
base_level: 0,
)
#let solution = thmbox(
"solution",
"Lösung",
// fill: rgb("#eee"),
// base_level: none,
// qed-symbol: $qed$,
// qed-symbol: $circle$,
stroke: black,
).with(numbering: none)
#let question = thmbox(
"question",
"Aufgabe",
// fill: rgb("#eee"),
base_level: 0,
stroke: black,
)
#let part = thmplain(
"part",
"",
base: "question",
// fill: rgb("fff"),
base_level: 0,
// thmfmt: "bold"
// titlefmt: strong
).with(numbering: "a)")
#let solutionorgrid(p: 10em, body) = {
v(-1.2em)
context if printanswersstate.get() {
solution[#body]
}
else {fillwithgrid(p)}
}
#let fillin(sol, width: 8em) = {
ifprintanswers(underline(sol), )}
#let definition = thmbox(
"definition",
"Definition",
base_level: 0,
fill: rgb("#eee"),
)
#let bemerkung = thmbox(
"bemerkung",
"Bemerkung",
// base_level: none,
fill: rgb("#eee"),
).with(numbering: none)
#let abrules(title: none, doc) = [
#if ( sys.inputs.at("answers", default: "false") =="true" ){
answers(true)
}
#set page(
// paper: "us-letter",
header: ( box(image("assets/logo.svg"), height: 2em)+ h(1fr)
+ifprintanswers(
"Lösung",
elsecontent: "Vorname Name:"+underlinespace(12em),
)
)
,
numbering: "1",
)
#{ifprintanswers({set document(title: context document.title + " -- Lösung")})}
#thmrules(doc)
]