Universe

Package version 0.1.0 Documentation manual PDF Typst Universe package page GitHub repository

party (noun) a gathering of parts

A Typst package for declaring and referencing named parts of a theorem with @theorem[@part].

Two theorems or solutions can each declare a part with the same key (such as <weakness>). Writing @first[@weakness] links directly to that item inside <first> (e.g. Solution 1(B))—even before <first> has been declared—while @first[local,@weakness] and #part-ref(<weakness>) print just the linked marker (B). party works out of the box with ctheorems, great-theorems, and custom theorem environments in both paged and HTML targets.

See the manual (Typst source) for full documentation and function reference, or view the Algebraic Geometry theorem & proof example (Typst source).

To get started, import party with:

#import "@preview/party:0.1.0"
#import party: items, part-label

Examples

Scoped part references with ctheorems

#import "@preview/party:0.1.0"
#import party: items, part-label
#import "@preview/ctheorems:2.0.0": thm-rules, thm-themes

#let solution = thm-themes.ams.proposition.with(supplement: "Solution", base: none)
#show: thm-rules
#show: party.ctheorems
#set enum(numbering: "(A)")

#solution[
  #items[
    The first solution tolerates heat.
  ][
    #part-label(<weakness>)
    It degrades in sunlight.
  ][
    Store it in an opaque container.
  ]
]<first>

#solution[
  #items[#part-label(<weakness>) The second solution degrades in humid air.][It tolerates sunlight.]
]<second>

Compare @first[@weakness] with @second[@weakness].

The last line prints Compare Solution 1(B) with Solution 2(A). Each link goes to the start of its item. In a proof, @first[local,@weakness] prints just the linked marker (B). Inside the solution itself, #party.part-ref("weakness") uses the enclosing solution as the parent.

Algebraic Geometry theorem and proof

See examples/algebraic-geometry.pdf (examples/algebraic-geometry.typ) for a complete single-page Algebraic Geometry showcase establishing the degree thresholds ($d \ge 2g - 1$, $d \ge 2g$, and $d \ge 2g + 1$) for a line bundle $\mathcal{L} \in \mathrm{Pic}©$ on a smooth projective curve $C$ of genus $g$. It demonstrates:

  • Internal cross-references between parts of the theorem statement via #part-ref(<vanishing>) and #part-ref(<base-point-free>).
  • Step-by-step marker-only links (a), (b), and © inside the proof via @curve-bundles[local,@vanishing], @curve-bundles[local,@base-point-free], and @curve-bundles[local,@very-ample].
  • Forward and external theorem-qualified citations via @curve-bundles[@very-ample], @curve-bundles[@vanishing], and @curve-bundles[@base-point-free].

Custom numbering and item contents

Pass one positional content block per item, as in #items[#part-label(<key>) First.][Second.] (party.list is an alias for items). Lists inherit enum.numbering, enum.start, and enum.reversed by default, or override numbering and start locally:

#items(start: 3, numbering: "(i)")[
  An unnamed preliminary observation.
][
  #part-label(<weakness>)
  #set text(fill: blue)
  A part that can be cited; the token is written as \].
]

Here weakness is (iv).

  • Zero-based lists: Pass start: 0 with a pattern that represents zero, such as #items(start: 0, numbering: "(1)")[Initial step.][Next step.] (printing (0) and (1)).
  • Paragraph spacing: In paged output, #items(end-par: false)[First.][Second.] uses the surrounding paragraph’s line spacing (par.leading) between the last item and following text instead of a full paragraph gap.
  • Scoped keys vs. native labels: Only part-label(<key>) (or part-label("key")) declares a theorem-scoped part key. A native Typst label inside an item (such as [The coating cracks. <observation>]) keeps its usual document-wide meaning.

Adapting other theorem packages

Install party.rules.with(parent-selector) after the theorem package’s own show rules, or use the preconfigured party.great-theorems adapter for great-theorems:0.1.2:

#import "@preview/party:0.1.0"
#import "@preview/great-theorems:0.1.2": great-theorems-init, mathblock

#let lemma = mathblock(blocktitle: "Lemma", counter: counter("lemma"))
#show: great-theorems-init
#show: party.great-theorems

#lemma[
  #party.items(start: 3, numbering: "(i)")[
    There is a least positive integer.
  ][
    #party.part-label(<uniqueness>)
    Any two least elements coincide.
  ]
]<least>

By @least[@uniqueness], the least positive integer is unique.

For any other theorem package, pass a selector matching the referenceable element that contains the theorem body and receives its trailing label (for instance, party.great-theorems is defined as party.rules.with(figure.where(kind: "great-theorem-counted"))).

  • Reference formatting: By default, string markers starting with ( or [ attach directly to the theorem reference (Solution 1(B)), while other markers are separated by a nonbreaking space (Solution 1 2.). Pass a custom formatter with format, e.g. #show: party.ctheorems.with(format: (parent, marker) => [#parent, part #marker]).
  • Supplement passthrough: Any bracketed supplement other than [@key] or [local,@key] follows the usual reference as written (@first[(draft)] prints Solution 1(draft) and @first[ (draft)] prints Solution 1 (draft)). Plain references, page references, and bibliography citations are untouched.

Local installation

With Typst 0.15.1 or later on Linux, run these commands from the root of the cloned repository so Typst resolves @local/party:0.1.0 to your checkout:

pkgdir="${XDG_DATA_HOME:-$HOME/.local/share}/typst/packages/local/party"
mkdir -p "$pkgdir"
ln -s "$PWD" "$pkgdir/0.1.0"

For other platforms, see the Typst local package documentation.

Examples and tests

party has no external runtime dependencies. Run these commands from the repository root to compile the manual and examples or run the test suite:

typst compile --root . docs/manual.typ
typst compile --root . examples/algebraic-geometry.typ
typst compile --root . examples/ctheorems.typ
typst compile --root . examples/great-theorems.typ
python3 tests/check.py

Change log

0.1.0

  • Initial release of party.
  • Add items() and list() for numbered theorem parts in paged and HTML targets, with numbering, start, and end-par options.
  • Add theorem-scoped part-label() and local marker-only part-ref().
  • Add rules(), ctheorems, and great-theorems show-rule adapters supporting @theorem[@part] and @theorem[local,@part] while preserving unrecognized supplements and standard references.