Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/preview/theoframe/0.3.0/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
local/*
assets/*.pdf
examples/
19 changes: 19 additions & 0 deletions packages/preview/theoframe/0.3.0/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2026 HeXiongwu <hexiongwu1995@foxmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
128 changes: 128 additions & 0 deletions packages/preview/theoframe/0.3.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# theoframe

This package provides theorem-like environments for academic writing in [Typst](https://typst.app/).
- Every environment supports cross-referencing via Typst's native reference system.
- Theorem numbering is composed of the level-1 heading number and a sequential letter (starting from `a`), and resets automatically at each level-1 heading (`= Heading`).
- Two visual styles are available through `theme.style`: `"minimal"` (inline header) and `"box"` (highlighted frame with colored border and background).
- The theme color is fully customizable, affecting titles, borders, background, and reference links.
- Theorem-like environments are classified into two distinct styles. Framed blocks — rendered with a highlighted border and background — include `Definition`, `Property`, `Axiom`, `Postulate`, `Assumption`, `Hypothesis`, `Conjecture`, `Proposition`, `Lemma`, `Theorem`, `Corollary`, `Remark`, and `Note`. Plain blocks — rendered without a frame — include `Proof`, `Example`, `Exercise`, `Problem`, `Solution`, and `Conclusion`. All environments support automatic numbering and multi-language localization.

## Basic Usage

To use, simply import the package and add a show rule:

```typst
#import "@preview/theoframe:0.3.0": *
#show: theoframe-setup
```

### Setup Options

The `#show: theoframe-setup` rule accepts a `theme` argument to customize the appearance of all theorem-like environments:


```typst
#show: theoframe-setup.with(theme: (style: "box", color: rgb("#067300")))
```


# Example

## style:"minimal"
```typst
#import "@preview/theoframe:0.3.0":*
#show: theoframe-setup
// #show: theoframe-setup.with(theme: (style: "box", color: rgb("#067300")))

#set page(paper:"a4", margin: 1cm)

= Preliminaries

This section introduces the basic definitions required for the subsequent results. We begin by formally defining even and odd integers, which form the foundation of our discussion on number-theoretic properties.

#definition(name: [Even Integer])[
An integer $n$ is called *even* if it is divisible by $2$, i.e., there exists an integer $k$ such that $n = 2k$.
]<def:even>

#definition(name: [Odd Integer])[
An integer $n$ is called *odd* if it is not divisible by $2$, i.e., there exists an integer $k$ such that $n = 2k + 1$.
]<def:odd>

= Main Results

Having established the basic definitions, we now present the main theoretical results of this note. We start with a fundamental theorem concerning the sum of even integers, followed by a natural corollary.

#theorem(name: [Sum of Two Even Integers])[
The sum of any two even integers is even.
]<thm:sum-even>

#proof(name: [Proof of @thm:sum-even])[
Let $a$ and $b$ be two even integers. By @def:even, there exist integers $k$ and $m$ such that $a = 2k$ and $b = 2m$. Then
$a + b = 2k + 2m = 2(k + m)$,
which shows that $a + b$ is divisible by $2$, hence even by @def:even.
]<pf:sum-even>

#corollary(name: [Sum of Multiple Even Integers])[
The sum of any finite number of even integers is even.
]<cor:sum-multiple>

#proof[
This follows directly from @thm:sum-even by induction on the number of terms.
]

= Additional Examples

To further illustrate the concepts introduced above, we provide a concrete example of even numbers and pose a related problem for the reader to solve.

#example(name: [Concrete Even Numbers])[
The integers $4$, $10$, and $16$ are even since $4 = 2 times 2$, $10 = 2 times 5$, and $16 = 2 times 8$.
]<ex:even-numbers>

#problem(name: [Sum of Two Odd Integers])[
Show that the sum of two odd integers is even.
]<prob:sum-odd>

#solution(name: [Solution to @prob:sum-odd])[
Let $a$ and $b$ be odd integers. By @def:odd, there exist integers $k$ and $m$ such that $a = 2k + 1$ and $b = 2m + 1$. Then
$a + b = (2k + 1) + (2m + 1) = 2k + 2m + 2 = 2(k + m + 1)$,
which is even by @def:even.
]<sol:sum-odd>
```

<p align="left">
<img src="./assets/example-minimal1.svg" alt="Minimal-style theorem-like environments rendered in Typst, including Definition, Theorem, Proof, Corollary, Example, Problem, and Solution with clean bold headers and auto-numbering.">
</p>

## style:"box"

```typst
#import "@preview/theoframe:0.3.0":*
// #show: theoframe-setup
#show: theoframe-setup.with(theme: (style: "box", color: rgb("#067300")))
```

<p align="left">
<img src="./assets/example-box1.svg" alt="Box-style theorem-like environments rendered in Typst with colored frames, featuring Definition, Theorem, Proof, Corollary, Example, Problem, and Solution in a green theme.">
</p>


# Outline for theorems

```typst
#line(length: 100%)
// #show outline: it => {
// show heading: set text(fill: rgb("#067300"))
// it
// }
#outline(title: "Definitions", target: figure.where(kind: "definition"))
#outline(title: "Theorems", target: figure.where(kind: "theorem"))

#line(length: 100%)
#let fig-arr = kind-array.map(it => figure.where(kind: it))
#outline(title: "Theorems-like environment", target: selector.or(..fig-arr))
```
<p align="left">
<img src="./assets/example-box2.svg" alt="Typst outline output for theorem-like environments, displaying categorized lists of Definitions, Theorems, and combined theorem-like entries with linked numbering and titles.">
</p>


1 change: 1 addition & 0 deletions packages/preview/theoframe/0.3.0/assets/example-box1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/preview/theoframe/0.3.0/assets/example-box2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading