Skip to content

Commit

Permalink
feat: add theorem docs
Browse files Browse the repository at this point in the history
  • Loading branch information
otytlandsvik committed Feb 4, 2025
1 parent b4f4934 commit f324136
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib.typ
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,16 @@
"Definition",
inset: (x: 1.2em, top: 1em),
)
#let lemma = thmbox("lemma", "Lemma", fill: uit-gray-color.lighten(80%))
#let example = thmplain("example", "Example").with(numbering: none)
#let proof = thmproof("proof", "Proof")
// Disable numbering of equations inside a proof block
#let custom-proof-bodyfmt(body) = {
set math.equation(numbering: none)
proof-bodyfmt(body)
}
#let proof = thmproof("proof", "Proof", bodyfmt: custom-proof-bodyfmt).with(
numbering: none,
)

// Helper to display external codeblocks.
// Based on https://github.com/typst/typst/issues/1494
Expand Down
36 changes: 35 additions & 1 deletion template/chapters/figures.typ
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,45 @@ $ <equ:clock>

== Definitions and Theorems

To easily style and reference definitions, theorems, proofs and similar blocks, the ctheorems #footnote()[see #link("https://typst.app/universe/package/ctheorems/")] package is included.
A number of functions are defined which automatically generate titles, styling and numbering functionality.

#definition[
A natural number is called a #highlight[_prime number_] if it is greater
than 1 and cannot be written as the product of two smaller natural numbers.
]
] <def:natural-number>

The numbering follows the heading counter by default, and we can reference @def:natural-number, @th:comp-num or @le:divide just like any other figure.

#theorem[
There are arbitrarily long stretches of composite numbers.
] <th:comp-num>

Corollaries are related to theorems, and that their counter is therefore based on the previously defined theorem:

#corollary[
if $n$ divides two consecutive natural numbers, then $n = 1$.
]

#lemma[
If $n$ divides both $x$ and $y$, it also divides $x - y$.
] <le:divide>


We can also pass additional arguments to the functions, in order to for instance modify the title:

#proof([of @th:comp-num])[
For any $n > 2$, consider$
n! + 2, quad n! + 3, quad ..., quad n! + n #qedhere
$
]

Note that for proofs, block equations are not numbered, and a _Q.E.D._ symbol (a black square) is automatically inserted in the right margin.
We can control where this symbol appears using `#qedhere`.

Finally, a lightweight example macro is exposed.
It is not numbered or referable, but has some simple styling rules applied.

#example[
Here is an example
]
Binary file modified template/thesis.pdf
Binary file not shown.

0 comments on commit f324136

Please sign in to comment.