diff --git a/lib/typst/local/handout/0.1.0/handout.typ b/lib/typst/local/handout/0.1.0/handout.typ index 583f993..33e92d1 100755 --- a/lib/typst/local/handout/0.1.0/handout.typ +++ b/lib/typst/local/handout/0.1.0/handout.typ @@ -151,34 +151,96 @@ // MARK: Sections // -#let generic(t) = block( - above: 8mm, - below: 2mm, - text(weight: "bold", t), -) - -#let _generic_base(kind, ..args) = { +/// Core render code for all objects (problems, theorems, etc) +/// This should never be used directly by client code. +/// +/// Args: +/// - kind: the kind of object to make ("Problem", "Definition", etc) +/// - label_name: a string. If provided, generate metadata for this object +/// under the given label. Labels must be unique, and are prefixed with `obj` +/// This label can then be used to reference this object. +/// +/// For example: +/// ``` +/// #problem(label: "problem1") +/// This is @obj:problem1 +/// ``` +#let _obj_base(kind, ..args, label_name: none) = { counter("obj").step() - if args.pos().len() == 0 { - generic([ - #kind - #context counter("obj").display(): - ]) + let n = context counter("obj").get().first() + + // The complete title text of this object, + // like "Problem 5:" or "Theorem: " + let obj_content = if args.pos().len() == 0 { + [#kind #n:] } else { - generic( - [ - #kind - #context counter("obj").display(): - ] - + " " - + args.pos().at(0), + [#kind #n: #args.pos().at(0)] + } + + // Render the object + block( + above: 8mm, + below: 2mm, + text(weight: "bold", obj_content), + ) + + // Generate labeled metadata for this object. + // + // This can be viewed directly with `#context query(