### Use Predefined Environments (Definition Example) Source: https://github.com/s15n/typst-thmbox/blob/main/README.md Thmbox provides several predefined environments like `definition`. You can omit the `title` parameter name when providing the title as the first argument. ```typ #definition["Typst"][ Let Typst be the coolest typesetting system. ] ``` -------------------------------- ### Initialize Thmbox Package Source: https://context7.com/s15n/typst-thmbox/llms.txt Initializes the thmbox package for the current document. It sets up heading numbering, configures the default sectioned counter, and installs the cross-reference resolver. The `counter-level` parameter controls the style of numbering. ```typ #import "@preview/thmbox:0.3.1": * // counter-level: 2 (default) → "Theorem 1.3" // counter-level: 1 → "Theorem 4" // counter-level: 3 → "Theorem 2.1.5" #show: thmbox-init(counter-level: 2) = Chapter One #theorem[Fundamental Theorem of Calculus][ If $f$ is continuous on $[a, b]$, then $integral_a^b f(x) dif x = F(b) - F(a)$. ] ``` -------------------------------- ### Install Thmbox Package Locally Source: https://github.com/s15n/typst-thmbox/blob/main/README.md To install the thmbox package locally, clone the repository into the appropriate local packages directory using Git. Ensure you replace `` with your system's specific data directory path. ```sh cd /typst/packages/local/thmbox git clone https://github.com/s15n/typst-thmbox.git 0.3.1 ``` -------------------------------- ### Proof Environment with Q.E.D. Source: https://context7.com/s15n/typst-thmbox/llms.txt Illustrates the `proof` environment, which includes an italic bold 'Proof:' header, the body text, and an automatically right-aligned Q.E.D. symbol. It supports an optional leading reference argument for 'Proof of Theorem X:' style headers and allows customization of the title and separator. ```typ #import "@preview/thmbox:0.3.1": * #show: thmbox-init() = Results #theorem[Infinitude of Primes][ There are infinitely many prime numbers. ] // Basic proof #proof[ Suppose there are finitely many primes $p_1, dots, p_n$. Consider $N = p_1 p_2 dots.c p_n + 1$. Then $N$ is not divisible by any $p_i$, contradicting the assumption. $qed()$ ] // Proof referencing a specific theorem — produces "Proof of Theorem 1.1:" #proof[@thm-primes][ Suppose there are finitely many primes... ] // Custom title and separator #proof(title: "Sketch", separator: ".")[ The key idea is a diagonal argument... ] ``` -------------------------------- ### Typst Thmbox Built-in Environments Source: https://context7.com/s15n/typst-thmbox/llms.txt Demonstrates the usage of various built-in theorem-like environments provided by the thmbox package, including definitions, theorems, proofs, and remarks. Ensure thmbox is imported and initialized. ```typ #import "@preview/thmbox:0.3.1": * #show: thmbox-init() = Linear Algebra #definition[Vector Space][ A *vector space* over $RR$ is a set $V$ with operations $+$ and $dot.c$ satisfying... ] #theorem[Dimension Theorem][ For a linear map $T: V -> W$, $ dim(ker T) + dim(im T) = dim V $ ] #proof[@dim-thm][ Choose a basis for $ker T$ and extend it to a basis for $V$... ] #corollary[ An injective linear map between spaces of equal dimension is an isomorphism. ] #lemma[Basis Extension][ Any linearly independent set can be extended to a basis. ] #example[ The set $RR^n$ with standard addition and scalar multiplication is a vector space. ] #remark[ The zero vector space {0} has dimension 0. ] #note[ The condition $dim V < infinity$ is required for the dimension theorem above. ] #exercise[ Prove that the intersection of two subspaces is itself a subspace. ] #algorithm[Gram–Schmidt][ Given linearly independent vectors $v_1, dots, v_n$, produce an orthonormal basis by iteratively subtracting projections. ] #claim[ Every finite-dimensional inner product space has an orthonormal basis. ] #axiom[Axiom of Choice][ Every collection of non-empty sets has a choice function. ] ``` -------------------------------- ### Customizing Thmbox with Fonts and RTL Layout Source: https://context7.com/s15n/typst-thmbox/llms.txt Demonstrates how to import Thmbox, initialize it, and customize font families for body and title text. Also shows how to enable right-to-left layout for specific environments. ```typ #import "@preview/thmbox:0.3.1": * #show: thmbox-init() // Custom fonts for all theorems in this document #let theorem = thmbox.with( color: colors.dark-red, variant: "Theorem", sans-fonts: ("Fira Sans",), title-fonts: ("Fira Sans",), ) // RTL box (e.g., for Arabic or Hebrew content) #thmbox( variant: "نظرية", color: blue, rtl: true,)[ هذا مثال على صندوق نظرية باللغة العربية. ] // Page-breaking thmbox (using figure show rule) #show figure.where(kind: "thmbox"): set block(breakable: true) #theorem[Long Result][ This theorem has a very long proof that may need to span multiple pages... ] ``` -------------------------------- ### Create a Basic Thmbox Environment Source: https://github.com/s15n/typst-thmbox/blob/main/README.md Use the `thmbox` function to create a basic environment. It can be referenced using label syntax like ``. ```typ #thmbox[ This is a basic Thmbox ] ``` -------------------------------- ### Using Thmbox with Built-in Color Palette Source: https://context7.com/s15n/typst-thmbox/llms.txt Shows how to import Thmbox and utilize the predefined color constants from the `colors` palette for the `color` and `fill` properties of thmbox environments. ```typ #import "@preview/thmbox:0.3.1": * #show: thmbox-init() // Access the color palette directly #thmbox( color: colors.dark-blue, fill: colors.light-aqua.lighten(80%), variant: "Observation",)[ The spectrum of a compact self-adjoint operator is countable. ] // Available named colors: // colors.dark-red, colors.orange, colors.lime, colors.green, // colors.light-turquoise, colors.turquoise, colors.light-aqua, // colors.aqua, colors.blue, colors.light-blue, colors.dark-blue, // colors.purple, colors.pink, colors.gray, colors.dark-gray ``` -------------------------------- ### Add a Proof Environment Source: https://github.com/s15n/typst-thmbox/blob/main/README.md Follow a theorem or statement with a `proof` environment to provide its justification. This environment is also part of the thmbox package. ```typ #proof[ Proven by obviousness. ] ``` -------------------------------- ### Import and Initialize Thmbox Package Source: https://github.com/s15n/typst-thmbox/blob/main/README.md Add these lines to the top of your Typst document to import the thmbox package and initialize its features. ```typ #import "@preview/thmbox:0.3.1": * #show: thmbox-init() ``` -------------------------------- ### Deriving Custom Typst Thmbox Environments Source: https://context7.com/s15n/typst-thmbox/llms.txt Shows how to create custom theorem-like environments by deriving from existing ones or `thmbox` directly using the `.with()` method. This allows for custom styling, labels, and numbering. ```typ #import "@preview/thmbox:0.3.1": * #show: thmbox-init() // Derive from note with custom color and label #let important = note.with( fill: rgb("#ffdcdc"), variant: "Important", color: red, ) // Derive from thmbox for a "Warning" box #let warning = thmbox.with( color: rgb("#e67e00"), fill: rgb("#fff3e0"), variant: "Warning", numbering: none, bar-thickness: 4pt, ) // Override default style of a predefined environment #let my-definition = definition.with(fill: rgb("#fffdd3")) = Usage #important[ Always normalize vectors before computing dot products in numerical code. ] #warning[ This theorem requires the field to have characteristic zero. ] #my-definition[Metric Space][ A metric space is a set $M$ with a distance function $d: M times M -> RR$ satisfying... ] ``` -------------------------------- ### proof Source: https://context7.com/s15n/typst-thmbox/llms.txt Renders a proof environment with an italic bold "Proof:" header, the body content, and an automatically right-aligned Q.E.D. symbol (□). It can accept an optional leading reference argument to customize the header. ```APIDOC ## proof — Proof environment with automatic Q.E.D. ### Description Renders a proof environment with an italic bold "Proof:" header, the body content, and an automatically right-aligned Q.E.D. symbol (□). It can accept an optional leading reference argument to customize the header. The "Proof" label translates automatically with the document language. ### Parameters #### Positional Arguments 1. **reference** (label) - Optional - A reference to a theorem or proposition to customize the header (e.g., "Proof of Theorem 1.2:"). 2. **body** (content) - Required - The content of the proof. #### Named Parameters - **title** (content) - Optional - Overrides the default "Proof:" header. - **separator** (content) - Optional - Overrides the default separator between the header and the body. ### Example ```typ #import "@preview/thmbox:0.3.1": * #show: thmbox-init() = Results #theorem[Infinitude of Primes][ There are infinitely many prime numbers. ] // Basic proof #proof[ Suppose there are finitely many primes $p_1, dots, p_n$. Consider $N = p_1 p_2 dots.c p_n + 1$. Then $N$ is not divisible by any $p_i$, contradicting the assumption. $qed()$ ] // Proof referencing a specific theorem — produces "Proof of Theorem 1.1:" #proof[@thm-primes][ Suppose there are finitely many primes... ] // Custom title and separator #proof(title: "Sketch", separator: ".")[ The key idea is a diagonal argument... ] ``` ``` -------------------------------- ### Apply Custom Rules to Predefined Environments Source: https://github.com/s15n/typst-thmbox/blob/main/README.md Redefine predefined environments to apply custom styling rules, such as background color, by using the `.with()` method and passing a dictionary of rules. ```typ #let my-thmbox-rules = ( fill: rgb("#fffdd3") ) #let my-definition = definition.with(..my-thmbox-rules) #my-definition[ This definition has a yellow background! ] ``` -------------------------------- ### Core `thmbox` Primitive Usage Source: https://context7.com/s15n/typst-thmbox/llms.txt Demonstrates the usage of the base `thmbox` function for creating theorem-like boxes. It shows minimal usage with just a body, usage with a title, fully specified arguments, named parameters for custom styling, unnumbered boxes, and cross-referencing. ```typ #import "@preview/thmbox:0.3.1": * #show: thmbox-init() = Introduction // Minimal usage — just a body #thmbox[This is a plain thmbox with default styling.] // With a title (2 positional args) #thmbox[Vector Space][ A vector space over a field $F$ is a set $V$ together with two operations... ] // Fully specified (3 positional args: variant, title, body) #thmbox[ "Key Result", "Cauchy–Schwarz Inequality", $|angle.l u, v angle.r|^2 <= angle.l u, u angle.r dot.c angle.l v, v angle.r$ ] // Named parameters with custom styling #thmbox( variant: "Important", title: "Don't Forget", color: red, fill: rgb("#ffeaea"), sans: false, bar-thickness: 5pt, )[ Always check boundary conditions. ] // Unnumbered box #thmbox(variant: "Hint", numbering: none)[ Try induction on the length of the sequence. ] // Cross-referencing See @vec-space for the definition. ``` -------------------------------- ### Derive Custom Thmbox Environment Source: https://github.com/s15n/typst-thmbox/blob/main/README.md Create a new custom thmbox environment by deriving from a predefined one (e.g., `note`) using the `.with()` method. This allows setting default parameters like `fill`, `variant`, and `color`. ```typ #let important = note.with( fill: rgb("#ffdcdc"), variant: "Important", color: red, ) #important[ This is in fact very important! ] ``` -------------------------------- ### thmbox-init Source: https://context7.com/s15n/typst-thmbox/llms.txt Initializes the thmbox package for the current document. This must be applied as a document-level show rule before using any thmbox environments. It configures heading numbering, the default sectioned counter, and the cross-reference resolver for thmbox figures. The `counter-level` parameter controls the depth of the counter numbering. ```APIDOC ## thmbox-init — Initialize the package for the current document ### Description Initializes the thmbox package for the current document. This must be applied as a document-level show rule before using any thmbox environments. It configures heading numbering, the default sectioned counter, and the cross-reference resolver for thmbox figures. The `counter-level` parameter controls the depth of the counter numbering. ### Parameters #### Named Parameters - **counter-level** (number) - Optional - Controls how many levels the default counter tracks (e.g., `2` produces `1.3`-style numbering; `1` produces a single global count). Defaults to `2`. ### Example ```typ #import "@preview/thmbox:0.3.1": * // counter-level: 2 (default) → "Theorem 1.3" // counter-level: 1 → "Theorem 4" // counter-level: 3 → "Theorem 2.1.5" #show: thmbox-init(counter-level: 2) = Chapter One #theorem[Fundamental Theorem of Calculus][ If $f$ is continuous on $[a, b]$, then $integral_a^b f(x) dif x = F(b) - F(a)$. ] ``` ``` -------------------------------- ### Configure Thmbox Counter Levels Source: https://github.com/s15n/typst-thmbox/blob/main/README.md Control the numbering levels for thmboxes using the `counter-level` parameter in `thmbox-init`. The default is 2 (chapter and reset per chapter). Setting it to 1 counts globally, 3 counts per section, etc. ```typ #show: thmbox-init(counter-level: 1) ``` -------------------------------- ### Registering Custom Sectioned Counters in Typst Thmbox Source: https://context7.com/s15n/typst-thmbox/llms.txt Illustrates how to register a custom Typst counter using `sectioned-counter` to enable automatic resetting at section boundaries, similar to the default thmbox counter. The custom counter is then passed to environments via the `counter` parameter. ```typ #import "@preview/thmbox:0.3.1": * // Declare counter before show rules #let exercise-counter = counter("exercise") #show: thmbox-init() // Register custom counter at level 1 (global, single number) #show: sectioned-counter(exercise-counter, level: 1) // Bind counter to an environment #let my-exercise = exercise.with(counter: exercise-counter) = Problem Set #my-exercise[ Let $f: RR -> RR$ be differentiable. Prove that if $f'(x) > 0$ for all $x$, then $f$ is strictly increasing. ] #my-exercise[ Show that $e^x >= 1 + x$ for all $x in RR$. ] // Exercises are numbered 1, 2, 3, ... globally (not reset per chapter) ``` -------------------------------- ### Standalone Q.E.D. Symbol Source: https://context7.com/s15n/typst-thmbox/llms.txt Shows how to use the `qed` function to insert a standalone, right-aligned tombstone symbol (□). This is useful for manual placement within proofs or anywhere in the body text where a Q.E.D. marker is needed. ```typ #import "@preview/thmbox:0.3.1": * #show: thmbox-init() // Manual placement inside a proof block #proof[ By contradiction. Assume $sqrt(2) = p/q$ in lowest terms. Then $2q^2 = p^2$, so $p$ is even... #qed() ] // Or placed anywhere in body text The argument concludes here. #qed() ``` -------------------------------- ### Use Custom Counters with Thmbox Source: https://github.com/s15n/typst-thmbox/blob/main/README.md Register and use custom counters with thmboxes. Define a counter using `counter()`, register it with `sectioned-counter(, level: )`, and then assign it to a custom thmbox using the `counter` parameter. ```typ #let exercise-counter = counter("exercise") #show: sectioned-counter(exercise-counter, level: 1) #let my-exercise = exercise.with(counter: exercise-counter) #my-exercise[The first exercise!] ``` -------------------------------- ### Style Thmbox with Parameters Source: https://github.com/s15n/typst-thmbox/blob/main/README.md Customize the appearance of a `thmbox` using the `variant`, `title`, and `color` parameters. The `color` parameter accepts standard color values like `red`. ```typ #thmbox( variant: "Important Theorem", title: "Fundamental Theorem of Math", color: red )[ A statement can only be believed if it is proven. ] ``` -------------------------------- ### thmbox Source: https://context7.com/s15n/typst-thmbox/llms.txt The foundational building block for all theorem-like boxes. It renders content inside a bordered, color-coded block with an auto-incrementing sectioned counter and an optional title. It is wrapped in a Typst `figure` element, allowing standard `set`/`show` rules to apply. ```APIDOC ## thmbox — Base environment for all theorem-like boxes ### Description The foundational building block for all theorem-like boxes. It renders content inside a bordered, color-coded block with an auto-incrementing sectioned counter and an optional title. It is wrapped in a Typst `figure` element, allowing standard `set`/`show` rules to apply. ### Parameters #### Positional Arguments (resolved last to first) 1. **body** (content) - Required - The main content of the box. 2. **title** (content) - Optional - The title displayed in the title bar. 3. **variant** (content) - Optional - The type of environment (e.g., "Theorem", "Definition"). #### Named Parameters - **variant** (content) - Optional - The type of environment (e.g., "Theorem", "Definition"). - **title** (content) - Optional - The title displayed in the title bar. - **numbering** (none or content) - Optional - Controls numbering. Set to `none` for unnumbered boxes. - **color** (color) - Optional - The color of the left bar. - **fill** (color) - Optional - The background fill color of the box. - **sans** (bool) - Optional - Whether to use sans-serif font for the title. - **bar-thickness** (length) - Optional - The thickness of the left bar. ### Example ```typ #import "@preview/thmbox:0.3.1": * #show: thmbox-init() = Introduction // Minimal usage — just a body #thmbox[This is a plain thmbox with default styling.] // With a title (2 positional args) #thmbox[Vector Space][ A vector space over a field $F$ is a set $V$ together with two operations... ] // Fully specified (3 positional args: variant, title, body) #thmbox[ "Key Result", "Cauchy–Schwarz Inequality", $|angle.l u, v angle.r|^2 <= angle.l u, u angle.r dot.c angle.l v, v angle.r$ ] // Named parameters with custom styling #thmbox( variant: "Important", title: "Don\'t Forget", color: red, fill: rgb("#ffeaea"), sans: false, bar-thickness: 5pt, )[ Always check boundary conditions. ] // Unnumbered box #thmbox(variant: "Hint", numbering: none)[ Try induction on the length of the sequence. ] // Cross-referencing See @vec-space for the definition. ``` ``` -------------------------------- ### qed Source: https://context7.com/s15n/typst-thmbox/llms.txt Inserts a right-aligned tombstone symbol (□) at the current position. This is useful for manually placing the Q.E.D. marker within a proof block or anywhere in the body text. ```APIDOC ## qed — Standalone Q.E.D. marker ### Description Inserts a right-aligned tombstone symbol (□) at the current position. This is useful for manually placing the Q.E.D. marker within a proof block or anywhere in the body text. ### Example ```typ #import "@preview/thmbox:0.3.1": * #show: thmbox-init() // Manual placement inside a proof block #proof[ By contradiction. Assume $sqrt(2) = p/q$ in lowest terms. Then $2q^2 = p^2$, so $p$ is even... #qed() ] // Or placed anywhere in body text The argument concludes here. #qed() ``` ``` -------------------------------- ### Enable Page Breaking for Thmboxes Source: https://github.com/s15n/typst-thmbox/blob/main/README.md By default, thmboxes are not breakable across pages. To enable page breaking, use a `show` rule targeting figures of `kind: "thmbox"` and set `block(breakable: true)`. ```typ #show figure.where(kind: "thmbox"): set block(breakable: true) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.